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

Session save_path not working #985

Closed
syerad opened this issue Jul 11, 2016 · 14 comments

Comments

@syerad
Copy link

commented Jul 11, 2016

Trying to use a csrf-token validation I encountered a fault in Symfony session handling.

Using the default parameters for session handling:

handler_id:  session.handler.native_file
save_path:   "%kernel.root_dir%/../var/sessions/%kernel.environment%"

the session will never be populated with parameters.
So if I'm trying to validate the csrf-token (Form-Login) I'm always getting a validation error
because the stored session doesn't contain any parameter.

The session-file in var/sessions was created but it is empty all the time.

My workaround was to set thesave_path to~.
This will set the save_path to the php session path.

Is it a known problem or am I doing something wrong?

Symfony 3.1.2

@Tobion

This comment has been minimized.

Copy link
Member

commented Jul 11, 2016

Looks like a duplicate of symfony/symfony#17715 and symfony/symfony#17845 (permission problem most likely).

@syerad

This comment has been minimized.

Copy link
Author

commented Jul 11, 2016

Yes, maybe. I'll try to figure out what's the problem.
Don't know if it is an permission problem.
By the way I'm using Php 5.6 and nginx

@hacfi

This comment has been minimized.

Copy link

commented Jul 11, 2016

@syerad I just tried the settings you posted above and it works fine on my machine with nginx, php 7 (worked with 5.6 previously as well) and Symfony 3.1.2. Try if chmod -R 0777 var/sessions helps fixing the permission issues.

@syerad

This comment has been minimized.

Copy link
Author

commented Jul 12, 2016

Hey, I already tried to chmod -R 0777. For me it doesn't work.

Seems that some other people have the same problem:

http://stackoverflow.com/questions/35208299/symfony-3-0-1-csrf-token-present-but-invalid

@xabbuh

This comment has been minimized.

Copy link
Member

commented Jul 12, 2016

@syerad Do you use Vagrant or the like?

@syerad

This comment has been minimized.

Copy link
Author

commented Jul 12, 2016

Yes, the dev environment is inside a vagrant box.
Is there any known issue using Vagrant?

@xabbuh

This comment has been minimized.

Copy link
Member

commented Jul 12, 2016

@syerad Try move the save path to a directory that is not shared between host and guest.

@syerad

This comment has been minimized.

Copy link
Author

commented Jul 12, 2016

@xabbuh It Works! Thx! Do you have an explanation why it doesn't work using a shared folder?
Permission issues?

@Tobion Tobion closed this Jul 12, 2016
@syerad

This comment has been minimized.

Copy link
Author

commented Jul 14, 2016

@xabbuh do you know why using a shared folder for sessions is not working?

@xabbuh

This comment has been minimized.

Copy link
Member

commented Jul 15, 2016

@syerad Sorry, I have no satisfactory explanation for this issue. However, I generally move files that are written by the application (cache, logs, and sessions) out of the shared folder to avoid any issues.

@syerad

This comment has been minimized.

Copy link
Author

commented Jul 15, 2016

Ok, thx 👍

@bocharsky-bw

This comment has been minimized.

Copy link
Contributor

commented Jul 15, 2016

@xabbuh I'm wondering how do you get an autocompletion in this case? Symfony plugin reads a lot of cached files to make autocompletion possible. Is there any solution?

@michelepatrassi

This comment has been minimized.

Copy link

commented Sep 20, 2016

@xabbuh Thank u, it solved my problem (symfony 3 on vagrant using homestead)

@cdoublev

This comment has been minimized.

Copy link

commented Sep 26, 2016

Don't you think that this issue should stay open ? var/sessions is the default value for the current stable version. It is currently my first experience with Symfony and I spent 1 hour to figure out why my session values could not be writed. There is no warnings in the documentation and I think many people use Vagrant as their environment for development.

Edit: my comment made me realize that only CSRF token could not be writed in session. Flashbag works correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
7 participants
You can’t perform that action at this time.