Jump to content

Log In Seesion and DB...tits Up me thinks!!!


willpower

Recommended Posts

Hi

 

I have probably gone about this the wrong way...so please advise

 

1 User Logs in.

2. Session created

3. DB updated WHERE user_logged_in = true

 

Now this means that if I try and log in with a name already logged on, upon checking I can see that user is already loged in and then deny the new log on.

 

Which is the ONLY reason that I created the user_logged_in field

 

Now the problem lies, of course, when someone closes their browser and doesn't log out.  The session is destroyed but the DB field remains true.

 

How does one normally go about this. How can I create a system where I can identify who is logged in and therefore prevent duplicate log ins and allow this to cope with users not logging off?

 

Thanks

 

Will

Link to comment
https://forums.phpfreaks.com/topic/39286-log-in-seesion-and-dbtits-up-me-thinks/
Share on other sites

You also need to create a timestamp field, then this field needs to be updated anytime your user makes a page request.

 

You then run a cron job to query the database and delete any logged in users who have not made a request within say the last 10 minutes.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.