ALa Rihane
ALa Rihane

Reputation: 45

Laravel - Session variable disappear and reappear

In my Laravel application I'm using long polling, I'm using session_write_close(); to prevent the sleep() issue, in the same application I 'm saving some data in an array in the Laravel Session, and I use this data in an ajax request, the problem is that sometime, the variable disappear, but when I try one more time the variable reappear! so the variable is still in the session but why it's not detected in the first time ?? this is really strange behavior.

Upvotes: 0

Views: 571

Answers (1)

Marko
Marko

Reputation: 11002

Session is tricky sometimes, save it to somewhere else where it persists better. In the database or on file. I think you can configure your session in laravel to write to disk (text file) or in database. Use that instead.

http://laravel.com/docs/5.0/session#session-usage

http://laravel.com/docs/5.0/session#session-drivers

http://laravel.com/docs/5.0/session#database-sessions

And use session api for laravel!

Upvotes: 1

Related Questions