Home >Backend Development >PHP Problem >How to use php session_id function

How to use php session_id function

藏色散人
藏色散人Original
2019-05-26 09:41:433323browse

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.

How to use php session_id function

#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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn