PHP session_id() Function

What is session_id Function?

Explanation

The "session_id()" function is used to get or set the current session id.

Syntax:

string session_id(session)
or
string session (optional): Session ID

In the above syntax, first the function returns the session id for the specified "session", or one can set the "session ID".

Example :


<?php
session_start();
if (!$counter) {
session_register("counter");
}
echo session_id();
?>
Result :

9572605674b2cd40bd424e189cc5b207

In the above example the session ID is returned, this is also done only after session_start.

PHP Topics


Ask Questions

Ask Question