Contact Us Forum Rules Search Archive
WebProWorld Part of WebProNews.com
Page One Link To Us Edit Profile Private Messages Archives FAQ RSS Feeds  
 

Go Back   WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum
Subscribe to the Newsletter FREE!


Register FAQ Members List Calendar Arcade Chatbox Mark Forums Read

Web Programming Discussion Forum Working with an API? Developing a plugin? Writing a Mod or script for your favorite blog, Web 2.0 site or Forum? Welcome.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-17-2005, 02:51 PM
WebProWorld Pro
 

Join Date: Jan 2004
Location: Milton Keynes, UK
Posts: 117
DarrenPWS RepRank 0
Default Who is online php sessions mysql

Hi all,

Once again I have another problem...

I have an admin section on my site where users can create quotes etc.

I want to be able to only allow one of the two people who have permission to access the section to be logged on at any one time.

Similar to how this forum tells you who is and who isnt online etc.

At the moment, the idea I have is to use a table in mysql to store who is logged in.

If it is user 1, then when user 2 tries to log in, it would simply display a message.

However, it is easy to add user1 to the db when they log on, but how do i then remove them when they log out, assuming they close the window rather than click the "log off" button.

Make sense?

Please help me - I have never used cookies, and have basic experience with sessions, so please explain in a simplified manner.

THANK YOU!

Darren.
Reply With Quote
  #2 (permalink)  
Old 02-17-2005, 03:40 PM
WebProWorld Pro
 

Join Date: May 2004
Location: Austin, TX
Posts: 199
steve0 RepRank 0
Default

over-simplified explaination:
A super-simple way is to use a common username/password along with a session identifier.

When someone logs in .. set a cookie with a value equal to the unique identifier, then insert this identifier in a 'sessionID' table along with NOW() in another field. (you can add IP and other things as well)

At the top of each 'admin page' check the user cookie value against the current value in the sessionID table.. it is matches, UPDATE the field containing the NOW() value, (business as usual). If the value is different. die("System is in use");

Run a cron job to periodically purge the sessionID table of any entries where current time is > the field with the (NOW() + 15 minutes )value. Assuming the last person with privileges has not accessed an admin page in the last 15 minutes.

With only two people having access.. there would be little doubt of who is logged in if the other gets the 'system busy' message.

Hope this gives you some ideas

-steve
__________________
Hardcore Programming Solutions and Coffee Drinker
Reply With Quote
  #3 (permalink)  
Old 02-18-2005, 08:48 AM
WebProWorld Pro
 

Join Date: Jan 2004
Location: Milton Keynes, UK
Posts: 117
DarrenPWS RepRank 0
Default

Thanks steve0.

I will look into setting something like that up.

Can you tell me how to take away time in php?

D
Reply With Quote
Reply

  WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum
Tags: , , ,



Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Search Engine Optimization by vBSEO 3.2.0