我是symfony的业余爱好者。我想在我的代码中使用 Session_id
当我更改 php.ini 并将 session.auto.start 变量设置为true时,我会在 false 之后给出一个 symfony 错误,我应该使用这个参数
$session = new Session();
但现在我有一个新错误,当我执行 indexAction() 时:
An exception has been thrown during the rendering of a template ("Notice: A session had already been started - ignoring session_start() in C:\xampp\htdocs\artgirl\app\cache\dev\classes.php line 105") in "DotArtBundle:Basket:index.html.twig".
500 Internal Server Error - Twig_Error_Runtime
1 linked Exception: ErrorException »
篮子控制器:
class BasketController extends Controller {
public function getStaticAction(){
$session = new Session();
$session->start();
$em = $this->getDoctrine()->getManager();
$sql = "Select ... where basket_id = '".$session->getId()."'";
}
//###############################################
public function indexAction(){
$user = new User();
$form = $this->createFormBuilder($user)
->add('username', 'text')
->add('password', 'text')
->add('email', 'text')
->getForm();
return $this->render('DotArtBundle:Artist:register.html.twig', array('form' => $form->createView(l)));
}
}
我在我的 base.html.twig 中使用 getStaticAction()
{% set vPrice = render(controller('DotArtBundle:Basket:getStatic')) %}