Reputation: 77
php/symfony experts!
This question especially for you.
try this code example
/**
* @Route("/your-route", name="your-route")
*/
public function indexAction()
{
$this->get('session')->save();
sleep(10);
return $this->render('template.html.twig');
}
requests are performing in parallel in different browsers as expected, but why sequentially in the same browser?
Upvotes: 3
Views: 1916
Reputation: 617
Your code should perform in parallel, if the web server supports multiple parallel requests.
Normally, when a previous request is still running with session storage opened, and a subsequent request calls session_open()
trying to access that same session, executions stops until the previous request ends or its session is closed with session_write_close()
.
The Session::save()
method, which you are calling, does exactly this, so your code is correct.
I was facing your same issue, and then I realized that I was using the php built-in web server, which can process one single request at time.
Upvotes: 2
Reputation: 131
Different browsers start different sessions, so there is no session lock, but different tabs of one browser try to open the same session.
That's why you will have session lock as default behavior.
When you do $session->save()
-- you call session_write_close()
function and save your session in its file. And by default Symfony redefines session.save_path
value from your php.ini.
So it seems you need to check permissions on path "/your_project_path/app/../var/sessions/dev" See this issue: Warning: session_write_close(): Failed to write session data.... #17845.
Upvotes: 0