Home >php教程 >php手册 >php查看当前Session的ID实例

php查看当前Session的ID实例

WBOY
WBOYOriginal
2016-06-13 09:11:491152browse

php查看当前Session的ID实例

 这篇文章主要介绍了php查看当前Session的ID的方法,实例分析了两种常见的获取session中ID的技巧,非常具有实用价值,需要的朋友可以参考下

 

 

本文实例讲述了php查看当前Session的ID的方法。分享给大家供大家参考。具体如下:

有两种方法可以得到用户的session id,第一是使用session_id()函数,另外一种是使用内置的常量SID获得,SID包含了session id和session值

?

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");

?>

希望本文所述对大家的php程序设计有所帮助。

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