@hal.littel you can use session_id() function to get session_id in PHP, code:
1 2 3 4 5 6 7 8 9 |
<?php // Start session session_start(); // Get session id $id = session_id(); echo $id; |
@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.