I can't get the session value in symfony2 from the ueditor in the plug-in.
阿神
阿神 2017-05-16 16:44:49
0
2
496

symfony2 action里面 $session = $this->getRequest()->getSession(); $session->set('companyId', 1);

ueditor php文件 sessionstart(); echo $SESSION['companyId'];

阿神
阿神

闭关修行中......

reply all(2)
PHPzhong

sf2 encapsulates session, you don’t need to adjust session_start:

// 页面一:
$session = $this->getRequest()->getSession();
$session->set('key', 1);

// 页面二:
$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.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template