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?
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.comwith your own of course.