English [ˈseʃn] US [ˈsɛʃən]

n. Meeting, meeting; (court) session; session, semester; (a period of continuous activity)

Plural: sessions

php session_id() function syntax

Function:Get/set the current session ID

Syntax: string session_id ([string $id])

Parameters :

ParameterDescription
id If id is specified parameter value, the specified value is used as the session ID. The session_id() function must be called before calling the session_start() function.

Description: session_id() returns the current session ID. If there is no current session, an empty string ("") is returned.

php session_id() function example

<?php
session_id(1);
session_start();
var_dump(session_id());
?>

Run instance»

Click the "Run instance" button to view the online instance

Output:

string(1) "1"
<?php
session_start();
session_id(2);
echo session_id();
?>
Run Instance»

Click the "Run Instance" button to view the online instance

Output:

2