Reputation: 4944
I put this on my index file:
session_set_cookie_params(31536000);
session_start();
It keeps users logged in even when the browser is closed and re-opened.
However, it only works when a WWW in front of my URL. Is there a way to make it work without the WWW in front of the URL?
Upvotes: 2
Views: 128
Reputation: 22783
As per the docs, use this:
session_set_cookie_params( 31536000, '/', '.example.com' )
;
This will allow the session cookie to be valid for every path (second argument) and every subdomain of example.com
(third argument). Replace .example.com
with your own of course.
Upvotes: 4