Home >Backend Development >PHP Tutorial >PHP View the ID instance of the current Session_PHP tutorial

PHP View the ID instance of the current Session_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:03:29858browse

php View the ID instance of the current Session

This article mainly introduces the method of viewing the ID of the current Session in php. The example analyzes two common techniques for obtaining the ID in the session. , very practical value, friends in need can refer to it

The example in this article describes how to view the ID of the current Session in PHP. Share it with everyone for your reference. The details are as follows:

There are two ways to get the user's session id. The first is to use the session_id() function, and the other is to use the built-in constant SID. SID contains the session id and session value

?

1

2

3

4

5

6

7

8

9

10

11

session_start();

print("");

$sid = session_id();

print("Session ID returned by session_id(): ".$sid."n");

$sid = SID;

print("Session ID returned by SID: ".$sid."n");

$mysite = $_SESSION["mysite"];

print("Value of mysite has been retrieved: ".$mysite."n");

print("n");

?>

1 2

3

4 5

67 8 9 10 11
session_start();
print(""); $sid = session_id(); print("Session ID returned by session_id(): ".$sid."n"); $sid = SID; print("Session ID returned by SID: ".$sid."n"); $mysite = $_SESSION["mysite"]; print("Value of mysite has been retrieved: ".$mysite."n"); print("n"); ?>
I hope this article will be helpful to everyone’s PHP programming design. http://www.bkjia.com/PHPjc/968667.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/968667.htmlTechArticlephp check the ID of the current Session. This article mainly introduces the method of checking the ID of the current Session in php, and example analysis. Two common techniques for obtaining the ID in the session are very practical...
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