php session_id function is used to get/set the current session ID. Its syntax is string session_id ([ string $id ]). The parameter id means that if the value of the id parameter is specified, the specified value will be used as the session ID.
#php session_id function how to use?
Function: Get/set the current session ID
Syntax:
string session_id ([ string $id ] )
Parameters:
id If the value of the id parameter is specified, use the specified value as the session ID. The session_id() function must be called before the session_start() function is called.
Description:
session_id() returns the current session ID. If there is no current session, an empty string ("") is returned.
php session_id() function usage example 1
<?php session_id(1); session_start(); var_dump(session_id()); ?>
Output:
string(1) "1"
php session_id() function usage example 2
<?php session_start(); session_id(2); echo session_id(); ?>
Output:
2
The above is the detailed content of How to use php session_id function. For more information, please follow other related articles on the PHP Chinese website!