A few things:
1.) Session ID should not be a constant value for a specific user. This is a security breach. Session ID must change every time. Ideally, this should be a random value.
2.) It does not look like you are setting a session id. You set a session variable called "uid".
3.) Have you ever called session_start() ?
Although I really do not recommend setting the session identifier to a constant value, you can set the session ID using the session_id () function:
$session_id = "some_random_value"; session_id($session_id);
But, as I said, this should not be a user ID. You can save the user ID as session information and check when the user loads the page to see if they are logged in.
if (isset($_SESSION["user_id"])) { //user is logged in $user_id = $_SESSION["user_id"]; } else { //make user log in $user_id = result_of_login(); $_SESSION["user_id"] = $user_id; }
For more information on PHP sessions, see the documentation.
source share