The PHP Function Session_Name
PHP is an integral part of full-stack web development. Simplilearn’s Post Graduate Program in Full Stack Web Development offers you the opportunity to learn everything about this programming language.
Sessions are a way to store data on the server instead of a remote client’s computer and to retrieve it later. It’s a great option to use when dealing with sensitive information, such as passwords.
By default, Sessions are stored in /tmp (on *nix systems like Linux) and any system user can read them. However, this isn’t very secure and you should change the session storage path using the session_set_save_handler() function.
The php function session_name() sets the name of the current Session and it’s also used in the cookie sent to the client’s browser. By default, the session name is PHPSESSID. However, you can give it a custom name using this function.
This function also allows you to set the lifespan of the Session. The value is in seconds and it defines how long this particular session will last. After that time, the session will expire and it will be closed. PHP will automatically close the session if you exit the web browser, but you can also destroy it manually using two functions. The session_unset() function clears the $_SESSION variables and the session_destroy() function deletes both the server side ($_SESSION) and the cookies from the client’s browser. Both of these functions should be called before calling session_start().