# Doubts in Login - Session

**URL:** <https://www.ruby-forum.com/t/doubts-in-login-session/71492>\
**Category:** Rails\
**Created:** [October 9, 2006, 12:46pm UTC](https://www.ruby-forum.com/t/doubts-in-login-session/71492 "2006-10-09T12:46:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![narayana](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/f6c823/32.png) [@narayana](https://www.ruby-forum.com/u/narayana)\
**Post date:** [October 9, 2006, 12:46pm UTC](https://www.ruby-forum.com/t/doubts-in-login-session/71492/1 "2006-10-09T12:46:48Z")

</div>

Hi Friendz,

I am using Login generator in my application.

I need clarification:  
for ex:

If a user login to the app. from one system. He shouldnot be allowed  
to login from another System at the same time. i.e Each User can login  
to the app. once at a time. can u Guys plz tell me , how to tackle this  
task.

Advance Thx,  
Regards,  
Karthick.

---

<div class="post-metadata">

**Author:** ![narayana](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/f6c823/32.png) [@narayana](https://www.ruby-forum.com/u/narayana)\
**Post date:** [October 9, 2006, 3:26pm UTC](https://www.ruby-forum.com/t/doubts-in-login-session/71492/2 "2006-10-09T15:26:13Z")

</div>

Jason N. wrote:

> You could create a logged-in users table, log their user id an IP. Also  
> their session ID?  
> When users log in, check to make sure their user ID isn’t in the table,  
> then write their connection to the table.  
> When they log out, delete the entry.  
> But what if they just disconnect and don’t log out? You’ll need to do  
> some sort of housekeeping every so often on sessions/logged connections.  
> I’ve not tackled this problem yet, but you’d probably have to do it from  
> a cron job. I have several rails tasks that run only from cron and it  
> works very well.  
> Let me know what you come up with
> 
> Jason

Hi Jason N.,

Thx for ur Logical mentor(useful for me). Can u Plz mail me /reply to  
this forum,  
some rails task that u are running from cron.(with explaination)

Advance Thx

Regards,  
Karthick.

---

<div class="post-metadata">

**Author:** ![narayana](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/f6c823/32.png) [@narayana](https://www.ruby-forum.com/u/narayana)\
**Post date:** [October 9, 2006, 2:25pm UTC](https://www.ruby-forum.com/t/doubts-in-login-session/71492/3 "2006-10-09T14:25:28Z")

</div>

You could create a logged-in users table, log their user id an IP. Also  
their session ID?  
When users log in, check to make sure their user ID isn’t in the table,  
then write their connection to the table.  
When they log out, delete the entry.  
But what if they just disconnect and don’t log out? You’ll need to do  
some sort of housekeeping every so often on sessions/logged connections.  
I’ve not tackled this problem yet, but you’d probably have to do it from  
a cron job. I have several rails tasks that run only from cron and it  
works very well.  
Let me know what you come up with

Jason

---

<div class="post-metadata">

**Author:** ![narayana](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/f6c823/32.png) [@narayana](https://www.ruby-forum.com/u/narayana)\
**Post date:** [October 9, 2006, 8:44pm UTC](https://www.ruby-forum.com/t/doubts-in-login-session/71492/4 "2006-10-09T20:44:35Z")

</div>

We use a class method call to send mass mailings every morning. Cron  
calls a shell script which does something like

/home/rails/emailapplication/script/runner -e production  
‘Emailer.send\_daily\_announcements’

I haven’t done this using an ActionController method, but anything you  
want to run from a script should be able to run from a model.  
This was just hacked out by a couple of rails noobs, so if anyone has a  
better way to do it, I’d love to hear about it.

Jason
