Home > Article > Backend Development > How to use php session_name function
php session_name function is used to read/set the session name. Its syntax is string session_name ([ string $name ]). The parameter session_name returns the current session name.
#How to use php session_name function?
Function: Read/set session name
Syntax:
string session_name ([ string $name ] )
Parameters:
session_name Returns the current session name. If the name parameter is specified, the session_name() function updates the session name and returns the original session name.
Description:
name The session name used in cookies or URLs, for example: PHPSESSID.
Only letters and numbers can be used as the session name. It is recommended that it be as short as possible and that it is a meaningful name (for users who have enabled cookie warnings, it is convenient for them to determine whether to allow this cookie. ). If the name parameter is specified, the current session will also use the specified value as its name.
php session_name() function usage example 1
<?php session_start(); session_name("name"); echo session_name() ; ?>
Output:
name
php session_name() function usage example 2
<?php session_start(); session_name("php中文网"); echo session_name() ; ?>
Output:
php中文网
The above is the detailed content of How to use php session_name function. For more information, please follow other related articles on the PHP Chinese website!