Categories:
.NET (357)
C (330)
C++ (183)
CSS (84)
DBA (2)
General (7)
HTML (4)
Java (574)
JavaScript (106)
JSP (66)
Oracle (114)
Perl (46)
Perl (1)
PHP (1)
PL/SQL (1)
RSS (51)
Software QA (13)
SQL Server (1)
Windows (1)
XHTML (173)
Other Resources:
How To Retrieve the Session ID of the Current Session
How To Retrieve the Session ID of the Current Session? - PHP Script Tips - Understanding and Using Sessions
✍: FYIcenter.com
Normally, you don't need to know the session ID of the current session. But if you are interested to know the session ID created by the PHP engine, there are two ways to get it:
The tutorial PHP script below shows you how to retrieve the session ID in two ways:
<?php
session_start();
print("<html><pre>");
$sid = session_id();
print("Session ID returned by session_id(): ".$sid."\n");
$sid = SID;
print("Session ID returned by SID: ".$sid."\n");
$myLogin = $_SESSION["MyLogin"];
print("Value of MyLogin has been retrieved: ".$myLogin."\n");
$myColor = $_SESSION["MyColor"];
print("Value of MyColor has been retrieved: ".$myColor."\n");
print("</pre></html>\n");
?>
You need to save this script to your Web server as next_page.php. Now visit first_page.php and click the "Next Page" hyper like, you will get something like this:
Session ID returned by session_id(): rfnq17ui6c7g6pjbtc46n0vi97 Session ID returned by SID: PHPSESSID=rfnq17ui6c7g6pjbtc46n0vi97 Value of MyLogin has been retrieved: FYICenter Value of MyColor has been retrieved: Blue
Now you know that the session ID created by the PHP engine is 26 characters long with alphanumeric characters only.
2007-04-18, 4991👍, 0💬
Popular Posts:
Write out a function that prints out all the permutations of a string. For example, abc would give y...
Explain in detail the fundamental of connection pooling? When a connection is opened first time a co...
What Happens to Indexes If You Drop a Table? - Oracle DBA FAQ - Managing Oracle Table Indexes If you...
What Does a HTML Document Look Like? A HTML document is a normal text file with predefined tags mixe...
How could Java classes direct program messages to the system console, but error messages, say to a f...