Laravel Session Not Saving
Every time I post a form, it would redirect back to the requesting page and I could not figure out why...

I spent HOURS googling and combing through articles after articles but couldn't find the answer

I added a test route with the following logic below and found out that it was creating a new session on each request!
Route::get('test', function()
{
echo 'Session ID = '.Session::getId();
});
After figuring out that a new session id was being created for each request, I modified my google search keywords then found better search result and ultimately this article that helped me solve this problem...
As mentioned on the article, I had a blank space before
<?php
tag in app/config/app.php file!!!! and this one white space caused it to create a new session every time... 


If you are experiencing this issue, please check all the php files in config folder, such as app.php, database.php, mail.php, session.php, etc, and if they have any white space or line break before <?php</source] on the first line then it will recreate session on every request... unbelievable

Thank you rpg999 for figuring out this problem and sharing on laravel.io 7 years ago

Leave a comment
If you sign up and log in:
OK, Sign me up!
However, there are times when unintended content is converted to emoticon because the content happens to have one of the emoticon symbols. That's why it's always good idea to preview your comment before posting and when you see this type of problem, you can indicate NOT to auto convert.