Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.0] Session key persistence issues - File Driver #8244

Closed
stevebauman opened this issue Apr 1, 2015 · 4 comments
Closed

[5.0] Session key persistence issues - File Driver #8244

stevebauman opened this issue Apr 1, 2015 · 4 comments

Comments

@stevebauman
Copy link
Contributor

The problem I'm going to describe only happens on Laravel 5, this issue is actually non-existent on Laravel 4.2, and the example shown below works just fine.

Inside your laravel 5 application in your routes file, set any session key, then change it like below:

//routes.php

Session::set('test', 'testing');
Session::get('test'); // Returns 'testing'

Session::set('test', 'changed');
Session::get('test'); // Returns 'changed'

Now retrieve the session key in any controller using Session::get('test'), it will return testing when it should return changed? Why does it return changed in my routes file but not inside my controllers?

I haven't tried other drivers, but this definitely occurs on the file driver. I've discovered that once you delete the session file inside the storage, it will successfully return changed, but only when you've manually deleted the session file will it properly change (due to it creating another session with the proper variables).

I've cleared all caches, called Session::forget('test'), and same issue occurs. It will always return 'testing' until a new session is created or until the session is destroyed. Is this intended?

EDIT: Also, inspecting the session file itself on Laravel 4.2 running on the same machine, once a session is created, and a Session::set() is called, it successfully updates the file with the proper session keys, however in Laravel 5, this file is never updated after it's created. This isn't an issue of permissions either, I'm running Windows 8.1, PHP 5.6, and the storage folder is completely wide open and writable, and I've also applied full permissions to the session file for any program/user.

@GrahamCampbell
Copy link
Member

Duplicate. This is a known issue. TLDR: The file driver is rubbish, but is fine for local testing.

@stevebauman
Copy link
Contributor Author

This looks like it's a matter of merely writing to the file again every time the set method is called. I'd have to disagree that this is fine for testing, because that's what I'm doing now, however I can't test with something that's not functioning correctly in the first place.

Note taken though, I'll use a different driver. This definitely appears to be only happening with the file driver. Any other driver seems fine for this specific issue.

Thanks!

EDIT: scratch that other comment. Had to clear route cache.

@garygreen
Copy link
Contributor

@GrahamCampbell hmm I see you mention the file driver is rubbish (for sessions) quite often, out of interest what's the issue with it exactly? Is it a performance thing or?

@Juddling
Copy link

Juddling commented Jul 2, 2015

I experience this issue testing locally too:

Laravel Framework version 5.1.3 (LTS)
PHP 5.6.7

@stevebauman stevebauman changed the title [Laravel 5] Session key persistence issues - File Driver [5.0] Session key persistence issues - File Driver Mar 21, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants