How can we get the current session id in PHP?

Last updated 2 years, 4 months ago | 751 views 75     5

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()