symfony2 action里面 $session = $this->getRequest()->getSession(); $session->set('companyId', 1);
ueditor php文件 sessionstart(); echo $SESSION['companyId'];
閉關(guān)修行中......
sf2 encapsulates session, you don’t need to adjust session_start:
// 頁(yè)面一:
$session = $this->getRequest()->getSession();
$session->set('key', 1);
// 頁(yè)面二:
$session = $this->getRequest()->getSession();
echo $session->get('key');
Update:
If you want to use it alone, make sure your session key is valid in the cookie, adjust $session->start() yourself, and use $session->get('xxx') to get variables, do not use php There are native methods in it, and the Session class has encapsulated all of them.
In Symfony, Session exists in the Request object. In the controller, write this:
public funciton demoAction(Request $request)
{
// 不需要 $session->start()
$session = $request->getSession();
$session->set('test', 'test value');
var_dump($session->get('test'));
}
However, the components in Symfony can be used alone. As the topic mentioned by the subject, they can be used alone in the ueditor editor:
use Symfony\Component\HttpFoundation\Session\Session;
$session = new Session();
// 需要 $session->start();
$session->start();
$session->set('test', 'test value');
var_dump($session->get('test'));
Using Symfony components alone requires the use of autoload.