session_id

string session_id(string session_ID) 

Gets or sets session ID.

Returns:

Session ID; FALSE on error

Description:

Gets or sets the session ID. If you’re not using your own session handlers, it’s a good idea to let PHP take care of it for you. You can also retrieve the session ID using the SID constant. This can be used to append the session ID to URLs, although this can be automated by compiling PHP with transparent session support. Transparent session support has a performance hit, however, so should be used with care.

Version:

Existing since version 4.0

Example:

Show session ID
session_start(); 
if (!$counter) {
   session_register("counter"); 
} 
echo session_id(); 

Get PHP Functions Essential Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.