How to session_write_close() in Laravel?

天大地大妈咪最大 提交于 2019-12-10 16:58:11

问题


Running session_write_close() before sleep() in Laravel doesn't seem to be functioning as the session is still blocked from other requests until the current connection is complete.

I'm trying to sleep() in Laravel without blocking other requests. Found out that session_write_close() should resolve the problem as mentioned here: Long polling in Laravel (sleep() function make application freeze). But it doesn't work. sleep() is still blocking other requests.

The project app is a chat app using regular polling and long-polling: http://github.com/doncadavona/laravel-angularjs-chat

Directly to the code: https://github.com/doncadavona/laravel-angularjs-chat/blob/master/app/Http/Controllers/MessagesController.php


回答1:


Laravel doesn't use PHP's session handling functions. You must use

$request->session()->save();

to call a handler's write method. But, since Laravel also doesn't implement any session locking mechanism, you are unlikely to see any session related blocking, nor should you see any change in ajax behavior because you saved/closed the session.




回答2:


You can't use session_start() or session_write_close() in laravel.

Laravel doesn't seem to be functioning as the session is still blocked from other requests until the current connection is complete.

This is already a nature of PHP, thats why AJAX was created in order for us to have multiple request at the same time.



来源:https://stackoverflow.com/questions/41544698/how-to-session-write-close-in-laravel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!