Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

mySQL Managing a login table

Posted on 2011-03-14
6
274 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

Suggested Solutions

Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
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…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

856 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