View Full Version : already login
04-19-2004, 08:31 AM
good day all.
how php script (to know that someone already login with my username?)
As a single feature, this requires quite some overhead. So you can best do this if your complete sessionmanagement is also database-based. As outlined belowe.
You create a table inside your database, where you insert a record each time a user logs in. You need to have a column in that table with the state of the session + another column with the PHP session ID + another colun with the userID. Initialy this is set to 'active'. When the client logs out, you set it to 'closed'. When the user requests a page, you check if there is a record with that sessionID + status=active. If so then update this record and set a timestamp or datetime field to Now().
You create a cron-job (or scheduled task) that will run every 15 minutes and that updates all records to status='closed' if the last requested page is more then 15 minutes ago --> this will cause sessions to timout after maximum 29 minutes 59 seconds.
When a user tryes to login, you run a select to see if there is already a record with that userID with status=active. Very simple check, but managing the sessiontable requires the real work here.
Powered by vBulletin® Version 4.2.2 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.