Solved

mySQL Managing a login table

Posted on 2011-03-14
6
276 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
[X]
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
  • 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
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

 

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…

630 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