PHP » Cookies and Sessions » session_id()

Syntax:
string session_id([string sid])
sid
New session ID. If this is parameter is used, the session_start() call must come after.

Gets/sets the session ID.

This function returns the session ID created with session_start(). It can also be used to change the session ID.

Examples

Code:
<?php

session_id("mySessionID");
session_start();
print "My session ID is: " . session_id();
session_destroy();

?>
Output:
My session ID is: mySessionID
Explanation:

The example shows how session_id() can be used to set the ID for the session.

See Also: