I want to be able to keep a PHP session, even after the browser has been closed. I know on this question, they suggested using the session_set_cookie_parameters() parameter, but I am unable to find a working example of this that doesn’t expire and works across all directory on my domain. If someone could help out, it would be amazing.
Share
Session stands for “until browser is closed”.
Session is something that expires.
If you don’t want it to be expired, you’re probably don’t want a session at all. You better read on cookie too. I guess that’s what you need.
But You can use session_set_cookie_parameters() to give the session cookie a non-zero lifetime before starting the session, or set session.cookie_lifetime to non-zero.
Remeber
session_set_cookie_params()needs to be called before session_start() for every single page request. Read moreCode:
Output:
Array ( [lifetime] => 1800 [path] => / [domain] => [secure] => )
Explanation:
Sets the cookie to expire after 30 minutes and be available anywhere on the site.