php session_id()s check

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
bucsi
Forum Newbie
Posts: 2
Joined: Thu Jan 22, 2004 2:11 am

php session_id()s check

Post 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...)
User avatar
kendall
Forum Regular
Posts: 852
Joined: Tue Jul 30, 2002 10:21 am
Location: Trinidad, West Indies
Contact:

Post 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
bucsi
Forum Newbie
Posts: 2
Joined: Thu Jan 22, 2004 2:11 am

Post by bucsi »

Thank You !

I try to use it.
Post Reply