Quote:
Originally Posted by ravi951
hi all,
i have written a code in php that will check whether the session exists
or not and it will generate the session id.
below is the code.....
PHP Code:
<?php
session_start();
mysql_connect("localhost","root","") or die("mysql_error()");
mysql_select_db("shopping") or die("mysql_error()");
if(!isset($_SESSION['username']))
{
print "Your SessionID: ".time();
}
else
{
print "Session does not exist";
}
?>
now i want that session id to be assigned to each user.
tell me how to do it....
|
can be explain me a bit more.
as far as i can understand, you want a unique id for every user in session whenever he logs in.
if i am right then you can follow these steps:
save the id with the username in it (will help you later) like Session id 100090009-1 where 1 is the user id.
Once the user logs in, the session id will be created and stored in session variable. try to add the variable inside an array something like $_SESSION['user']['id'] (just easy to manage things. If you want the whole user data stored in session you can have print_r $_SESSION['user'] and you will get all the stored data instead of tracking the code).
Let me know if this helped you or you still have doubts.