pnyx Posted March 9, 2009 Share Posted March 9, 2009 Hello! I'm pretty noob in php and SQL. Usually I use joomla for createing webpages. So i'll planning to use joomla for my new project..just useing some modul like - "login" I know how to get data from database and how to upload data e.t.c. Here is my problem: I just don't understand how the script understands which user is logged in. I know that users have ID-s in database. And there is an option ...for example: *If the user is logged in - value = 1 *If not - value = 0 I can handle with one user online...(vith value = 1) But if there is like 200 users online.... I need a hint or a peace of script...some kind of explanation...have been stucked with this too long... I need something like this: - check status -if offline echo **** -if online echo users personal info (for example) Incase a copy of joomla created database: Users: id int(11) auto_increment name varchar(50) latin1_swedish_ci username varchar(25) latin1_swedish_ci email varchar(100) latin1_swedish_ci password varchar(100) latin1_swedish_ci usertype varchar(25) latin1_swedish_ci block tinyint(4) 0 sendEmail tinyint(4) 0 gid tinyint(3) UNSIGNED 1 registerDate datetime 0000-00-00 00:00:00 lastvisitDate datetime 0000-00-00 00:00:00 activation varchar(100) latin1_swedish_ci params text latin1_swedish_ci Session: username varchar(50) latin1_swedish_ci time varchar(14) latin1_swedish_ci session_id varchar(200) latin1_swedish_ci 0 guest tinyint(4) 1 userid int(11) 0 usertype varchar(50) latin1_swedish_ci gid tinyint(3) UNSIGNED 0 Thank you thank you if you find some time to help. Quote Link to comment https://forums.phpfreaks.com/topic/148651-help-with-sessionusers-need-an-explanation/ Share on other sites More sharing options...
revraz Posted March 9, 2009 Share Posted March 9, 2009 The 1 or 0 in your example above is a TRUE / FALSE setting, not the actual count of users online. So since each person has their own session, having a session variable set to 1 or TRUE when they log in carries from page to page with them saying they logged in. You can also store their ROW ID in a session to identify who they are when needed. Quote Link to comment https://forums.phpfreaks.com/topic/148651-help-with-sessionusers-need-an-explanation/#findComment-780612 Share on other sites More sharing options...
pnyx Posted March 10, 2009 Author Share Posted March 10, 2009 Thank you for your time. Yeah, I understan that it is true or false. But i don't understand how the script knows that this concrete person is logged in. I can make separate lines - if user_id 1 session_id = 1 show page **** if user_id 2 session_id = 1 show page **** if user_id 3 session_id = 1 show page **** But it looks stupid...and pointless...maybe i'm going to have 1000000 users... Hope you understand... Quote Link to comment https://forums.phpfreaks.com/topic/148651-help-with-sessionusers-need-an-explanation/#findComment-780966 Share on other sites More sharing options...
waynew Posted March 10, 2009 Share Posted March 10, 2009 Each user has their own session id that ties their session variables to them. echo session_id(); You could also use cookies in correlation with server side sessions if you wish. Quote Link to comment https://forums.phpfreaks.com/topic/148651-help-with-sessionusers-need-an-explanation/#findComment-780976 Share on other sites More sharing options...
pnyx Posted March 10, 2009 Author Share Posted March 10, 2009 Each user has their own session id that ties their session variables to them. echo session_id(); You could also use cookies in correlation with server side sessions if you wish. So...how the script knows that it must use that conreet id...when user logs in.. Quote Link to comment https://forums.phpfreaks.com/topic/148651-help-with-sessionusers-need-an-explanation/#findComment-781024 Share on other sites More sharing options...
revraz Posted March 10, 2009 Share Posted March 10, 2009 Because each time you use session_start in other pages, if there is an existing session, it uses it. Quote Link to comment https://forums.phpfreaks.com/topic/148651-help-with-sessionusers-need-an-explanation/#findComment-781118 Share on other sites More sharing options...
JonnoTheDev Posted March 10, 2009 Share Posted March 10, 2009 Sessions may be hard to grasp at first for a noob. Read this, hopefully it will give you a better understanding of how php uses sessions. http://php.about.com/od/advancedphp/ss/php_sessions.htm Quote Link to comment https://forums.phpfreaks.com/topic/148651-help-with-sessionusers-need-an-explanation/#findComment-781134 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.