@hal.littel
In PHP, you can get the session ID using the session_id()
function. This function returns the current session ID or an empty string if no sessions are active.
Here's an example:
1 2 3 4 5 6 7 8 |
// Start the session session_start(); // Get the session ID $session_id = session_id(); // Print the session ID echo "Session ID: " . $session_id; |
Make sure to call session_start()
before using session_id()
to initialize the session and generate a session ID if none exists.