有两种方法可以得到用户的session id,第一是使用session_id()函数,另外一种是使用内置的常量SID获得,SID包含了session id和session值
<?php session_start(); print("<html><b>"); $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("</b></html>\n"); ?>