The php Function Session_Set_Cookie_Params
Cookies and Sessions are two ways that PHP allows websites to save information that is relevant for the same user across pages. This includes login details, products that a user has checked out and other information that can be remembered from page to page and across web requests.
Session variables are stored in the $_SESSION global array and can be accessed by PHP scripts from any page. This information is then sent to the browser via a session cookie. The browser can then return this information to the server with each request, which is used by the web server to identify the same user.
The php function session_set_cookie_params sets the cookie parameters for a session, including its lifespan and whether it should be transmitted securely or only over HTTPS. The parameter values are passed as an associative array to a setcookie() function, which then sets the cookie in the browser.
Other important session parameters include the session name, which should be unique to the current user and the cookie path, which should match the document that created the session. If the session is closed, the session cookie is also deleted from the browser.
Sessions can also be regenerated by using the session_regenerate_id() function. This creates a new session file with a different session ID and copies the data from the existing session to it. It then generates a new cookie for the session and sets the response headers to tell the browser that this is a renewal.