How can we get the current session id in PHP?

Last updated 5 years, 8 months ago | 3035 views 75     5

Tags:- PHP

session_id() function

There is a function session_id() in php which is use to get and/or set the current session id.

string session_id ([ string $id ] )

for getting session id in php we have to use session_id() function without parameter.

echo session_id()

if we want to set session id then we need to pass a parameter inside session_id() function. For this purpose we needs to be called session_id() function before session_start()