Tools, FAQ, Tutorials:
Retrieving Session ID from the Current Session in PHP
How To Retrieve the Session ID of the Current Session in PHP?
✍: 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.
⇒ Options to Transfer Session IDs in PHP
2016-10-26, 1506🔥, 0💬
Popular Posts:
How to send an FTP request with the urllib.request.urlopen() function? If an FTP server supports ano...
How to run PowerShell Commands in Dockerfile to change Windows Docker images? When building a new Wi...
Where to find tutorials on API Management Services at Azure Portal? Here is a list of tutorials to a...
How To Create an Array with a Sequence of Integers or Characters in PHP? The quickest way to create ...
How To Read a File in Binary Mode in PHP? If you have a file that stores binary data, like an execut...