Skip to content

Cookie expire time incorrect (Laravel 5.2) #42

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

Closed
isopropil opened this issue Jun 9, 2016 · 11 comments
Closed

Cookie expire time incorrect (Laravel 5.2) #42

isopropil opened this issue Jun 9, 2016 · 11 comments

Comments

@isopropil
Copy link

Trying to use with Laravel 5.2.
When Laravel set a cookie (session and csrf token), the expiration time of this cookies is in past.
Standart Laravel cookie lifetime - 2 hours, but I receive a cookie, that expired a hour ago. My current timezone - +0300. What happens?
Thank you.

@andig
Copy link
Contributor

andig commented Jun 9, 2016

Does the same setup work when you're serving via apache/nginx instead of php-pm?

@marcj
Copy link
Member

marcj commented Jun 9, 2016

looks like your timesettings are wrong. php-pm doesnt do anything special with cookies lifetime.

@isopropil
Copy link
Author

With nginx+php-fpm all works properly. Time settings also correct.

@isopropil
Copy link
Author

httpkernel-adapter modifying cookie lifetime.
Bridges/HttpKernel.php, line 223. Simply change gmdate to date.

@andig
Copy link
Contributor

andig commented Jul 4, 2016

@isopropil

httpkernel-adapter modifying cookie lifetime. Bridges/HttpKernel.php, line 223. Simply change gmdate to date.

According to http://stackoverflow.com/questions/21120882/the-date-time-format-used-in-http-headers it needs be GMT. So- where do we go wrong here? I also don't see why- if its wrong- this would differ from nginx and apache?

@isopropil
Copy link
Author

This describes only date format. But gmdate() returns a Greenwich time (time from "0" timezone).
Example:
echo date('D, d-M-Y H:i:s', time()). ' GMT'; // Tue, 19-Jul-2016 10:34:53 GMT
echo gmdate('D, d-M-Y H:i:s', time()). ' GMT'; // Tue, 19-Jul-2016 07:34:53 GMT
Also, Laravel with php-fpm and nginx set correct dates in cookies.

@andig
Copy link
Contributor

andig commented Jul 19, 2016

Could you push a small PR?

Am 19.07.2016 um 09:36 schrieb isopropil notifications@github.com:

This describes only date format. But gmdate() returns a Greenwich time (time from "0" timezone).
Example:
echo date('D, d-M-Y H:i:s', time()). ' GMT'; // Tue, 19-Jul-2016 10:34:53 GMT
echo gmdate('D, d-M-Y H:i:s', time()). ' GMT'; // Tue, 19-Jul-2016 07:34:53 GMT
Also, Laravel with php-fpm and nginx set correct dates in cookies.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.

@marcj
Copy link
Member

marcj commented Jul 19, 2016

All HTTP date/time stamps MUST be represented in Greenwich Mean Time (GMT), without exception.

So, seems to me, we're doing right. Is your timezone correctly set in php.ini (not of fpm/,cli/, but from cgi/ folder)?

gmdate doesn't return from 0 timezone, but from your set timezone. If this is wrong, gmdate will return wrong results. Since on ubuntu fpm/cgi/cli have different php.ini files chances are high you have just put your server-timezone into the wrong php.ini.

@marcj
Copy link
Member

marcj commented Jul 19, 2016

To make it more clear: on my ubuntu for example /etc/php/7.0/cgi/php.ini needs to have date.timezone = UTC if your server timezone (see date command) is UTC (which is highly recommended). If your server timezone is something-different, than your date.timezone of cgi/php.ini needs to have exactly this timezone as well.

@andig
Copy link
Contributor

andig commented Apr 16, 2018

ping @isopropil is this still an issue?

@andig
Copy link
Contributor

andig commented Aug 3, 2018

Closing due to missing feedback

@andig andig closed this as completed Aug 3, 2018
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

3 participants