Page 1 of 1

php session_id()s check

Posted: Thu Jan 22, 2004 2:11 am
by bucsi
Hi

I have to write a php site witch can use login/password.
But the login/password can access just olny one user in time.

My idea is I write the session_id (SID) to the table of user.
When somebody is logging in I compare the new user's SID and the
table of SID.

If it is not equal I would like to know is the SID of the table alive.

any idea ?
(sorry, i'm a beginner english student...)

Posted: Thu Jan 22, 2004 9:29 am
by kendall
busci,

I think i see where youre getting at....uhm you will need to make sure that everyone's password is unique for starters
You shud create a register_session_id("username") rather than a session id i think
Maybe have something to check the database at a certain time so that if a username is still active at a certain time or for a certain time so we will no if he is "alive" or not

im not good at writing scripts but

Code: Select all

if($user){
// check user against database to see if he is not logge din already
$user_logged_in = mysql_query("select user where user = user",$database); // i think you will need to check a timestamp for more accuracy
if(mysql_num_rows($user_logged_in)>0){
well the user is logged in so...something is wrong
}else{
register_session_id($user); // remember to have session_start() . propbably you cud add a timestamp to use in compare scenario
// register the user in the database
}
}else{
// incorrect user 
}
Its not the ala script but its to get the general idea....i guess someone else will be able to help elaborate to make it a lil clearer

Kendall

Posted: Thu Jan 22, 2004 4:57 pm
by bucsi
Thank You !

I try to use it.