Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

prasatharumugam's avatar

Laravel 4.2 Session non persistent

Hi I am using laravel 4.2. After my login code, I redirect to another route for dashboard. But session is not persistent on my dashboard function

This is my code on login function

Session::put('email', $userObject->email); Session::put('firstName', $userObject->first_name); Session::put('lastName', $userObject->last_name); Session::save();

return Redirect::to('/account/dashboard');

if i try to print Session::all() right after Session::save(); I could get the values, But after redirection got nothing. Of course my storage path has the write permissions (0777) Session driver is 'file' Also tried with database, but no luck Any help is highly appreciated, stuck on this for a week almost.

0 likes
6 replies
prasatharumugam's avatar

Flash data is also not working. Is there any solution for this? I have searched a lot but could not make it.

jusahah87's avatar

Are you sure authentication is successful? I had once similar issue and it was simply due the fact that authentication did not work as I expected (user somehow got logged out within same request)

prasatharumugam's avatar

I am sure that Authentication is successful. I tested with simple routes that sets session values. but no luck

prasatharumugam's avatar

Thanks @jusahah87 , @desaijay123 Thanks for your answers

I Found the issue.

Issue caused because of PHP closing tag on a payment gateway library. It was included in the autoload.

Things to check if session issue comes:

  1. Check for errors using debug true.
  2. Check for exceptions in log file(storage folder)
  3. Do not include PHP closing tag on your files. Before installing a custom library make sure that it doesnot have a closing tag or an error
  4. Do not copy code from websites. if you do so, just paste it to notepad and then copy paste to your editor

Please or to participate in this conversation.