Solved

mySQL Managing a login table

Posted on 2011-03-14
6
273 Views
Last Modified: 2012-05-11
Hi,

I'm building a scheduled task in mySQL that will, every night, run through a table of users who are logged into the system and automatically logoff anyone who's been logged in for 2 weeks.

My current draft runs through the Login table, identifying the users logged in for over 2 weeks and puts their details into a temp table. I then loop through the temp table running the stored proc that does the log-off for each temp table entry.

Can anyone think of a simpler way of doing this? Especially one that doesn't involve using a loop?

Thanks,
John.
0
Comment
Question by:GroganJ
  • 3
  • 3
6 Comments
 
LVL 3

Expert Comment

by:sbickerstaff
ID: 35130310
Is the app using PHP? if so, why not use sessions and set the expiry time to two weeks?
0
 

Author Comment

by:GroganJ
ID: 35130515
I thought about using session timeout, but there are a couple of other events in the DB that are triggered by a user logout. For that reason, I want to control / track it within the DB rather than from php.
0
 
LVL 3

Expert Comment

by:sbickerstaff
ID: 35130622
how are you maintaining / checking that someone is logged in?

1) are you setting the last login time when they log in?
2) have you a field to set that user is active each time they visit a page or do you just use last login time? or how do you check if user is active?

as someone can close the browser without logging out, then obviously they're not active anymore, so you could be forcing a log off that is an un-necessary overhead.

can you give an example of these 'other events' triggered by a log out?
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 

Author Comment

by:GroganJ
ID: 35130670
I am tracking when they login and when there is activity. After a predetermined period of inactivity, I want to log them out (for security reasons). At the moment, this is set to 2 weeks, but if when we change that, it's very easy to just update a stored proc and let it run.

The other events that get triggered don't really matter, but it's important that they get run when a user logs out (or is logged out by the system).
0
 
LVL 3

Accepted Solution

by:
sbickerstaff earned 500 total points
ID: 35130770
From what you've been saying then, in my opinion, whats you're doing at the minute sounds like the only way with one possible ammendment:

instead of putting all records out into a temp table and then processing them again, why not just process these records on the first loop through the database?
0
 

Author Closing Comment

by:GroganJ
ID: 35176723
Thanks for your input on this.
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Foreword In the years since this article was written, numerous hacking attacks have targeted password-protected web sites.  The storage of client passwords has become a subject of much discussion, some of it useful and some of it misguided.  Of cou…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question