# Sessions things I can't figure out from the api

**URL:** <https://www.ruby-forum.com/t/sessions-things-i-cant-figure-out-from-the-api/73986>\
**Category:** Rails\
**Created:** [October 28, 2006, 8:17pm UTC](https://www.ruby-forum.com/t/sessions-things-i-cant-figure-out-from-the-api/73986 "2006-10-28T20:17:47Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![craigrails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c2a13f/32.png) [@craigrails](https://www.ruby-forum.com/u/craigrails)\
**Post date:** [October 28, 2006, 8:17pm UTC](https://www.ruby-forum.com/t/sessions-things-i-cant-figure-out-from-the-api/73986/1 "2006-10-28T20:17:47Z")

</div>

I have a cron script that destroys sessions that are over 30 minutes,  
essentially running from library…

class SessionCleaner  
def self.remove\_stale\_sessions  
CGI::Session::ActiveRecordStore::Session  
Session.destroy\_all( [‘updated\_at \< ?’, 30.minutes.ago] )  
end  
end

which works fine. Sessions are ActiveRecord if that matters.

I have on my layout for this one particular model/controller,

which refreshes the screen every 5 minutes which means as long as they  
leave this screen open, their session is updated and never destroyed.

So I added to the model, in\_out.rb

:session :on, :except =\> %w(list)

and restarted the server but still, when this page is refreshed, so is  
the user’s session.

Is it possible to have a page set so that if it is refreshed, the  
session remains untouched?

Craig

---

<div class="post-metadata">

**Author:** ![craigrails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c2a13f/32.png) [@craigrails](https://www.ruby-forum.com/u/craigrails)\
**Post date:** [October 28, 2006, 8:21pm UTC](https://www.ruby-forum.com/t/sessions-things-i-cant-figure-out-from-the-api/73986/2 "2006-10-28T20:21:18Z")

</div>

Craig W. wrote:

> Is it possible to have a page set so that if it is refreshed, the  
> session remains untouched?

would that make any sense? why “refresh” if you don’t want to mark the  
user’s session as “still active”?

---

<div class="post-metadata">

**Author:** ![craigrails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c2a13f/32.png) [@craigrails](https://www.ruby-forum.com/u/craigrails)\
**Post date:** [October 28, 2006, 8:39pm UTC](https://www.ruby-forum.com/t/sessions-things-i-cant-figure-out-from-the-api/73986/3 "2006-10-28T20:39:48Z")

</div>

On Sat, 2006-10-28 at 20:21 +0200, None None wrote:

> Craig W. wrote:
> 
> > Is it possible to have a page set so that if it is refreshed, the  
> > session remains untouched?
> 
> would that make any sense? why “refresh” if you don’t want to mark the  
> user’s session as “still active”?

* * *

In this case, it is an ‘In Out’ board which lists the employees and  
whether they are in or out which is handy for a receptionist. But the  
receptionist also walks away from her desk and I would like this screen  
to refresh more frequently but not allow someone else to sit down with  
the receptionist’s authentication and access other areas.

Future plans are to:

- expire sessions more frequently
- not require a login for the list view at all

Craig

---

<div class="post-metadata">

**Author:** ![craigrails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c2a13f/32.png) [@craigrails](https://www.ruby-forum.com/u/craigrails)\
**Post date:** [October 29, 2006, 11:54pm UTC](https://www.ruby-forum.com/t/sessions-things-i-cant-figure-out-from-the-api/73986/4 "2006-10-29T23:54:04Z")

</div>

On Sat, 2006-10-28 at 11:14 -0700, Craig W. wrote:

> which works fine. Sessions are ActiveRecord if that matters.
> 
> and restarted the server but still, when this page is refreshed, so is  
> the user’s session.
> 
> Is it possible to have a page set so that if it is refreshed, the  
> session remains untouched?

* * *

even with ‘session :off’ in my in\_out.rb model, a refresh of my list  
view of this model still updates the session.

;-(

Anyone?

Craig

---

<div class="post-metadata">

**Author:** ![craigrails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c2a13f/32.png) [@craigrails](https://www.ruby-forum.com/u/craigrails)\
**Post date:** [November 7, 2006, 10:44am UTC](https://www.ruby-forum.com/t/sessions-things-i-cant-figure-out-from-the-api/73986/5 "2006-11-07T10:44:37Z")

</div>

On Sun, 2006-10-29 at 23:48 -0500, Long wrote:

> > > end  
> > > So I added to the model, in\_out.rb
> > 
> > * * *
> > 
> > even with ‘session :off’ in my in\_out.rb model, a refresh of my list  
> > view of this model still updates the session.
> 
> Again try in your controller…

* * *

I started in the controller, moved it to the model and sort of stayed  
with the model.

Anyway, moving it from model in\_out.rb to in\_outs\_controller.rb made no  
difference…a page refresh still updates the ActiveRecord session (Yes,  
I restarted the web server, logged out, deleted all sessions so I know  
this was a new, untainted session).

;-(

Craig

---

<div class="post-metadata">

**Author:** ![craigrails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c2a13f/32.png) [@craigrails](https://www.ruby-forum.com/u/craigrails)\
**Post date:** [November 7, 2006, 10:44am UTC](https://www.ruby-forum.com/t/sessions-things-i-cant-figure-out-from-the-api/73986/6 "2006-11-07T10:44:29Z")

</div>

Craig W. wrote:

> > end
> > 
> > :session :on, :except =\> %w(list)

Have you tried to use the above line in your controller?

> > and restarted the server but still, when this page is refreshed, so is  
> > the user’s session.
> > 
> > Is it possible to have a page set so that if it is refreshed, the  
> > session remains untouched?
> 
> * * *
> 
> even with ‘session :off’ in my in\_out.rb model, a refresh of my list  
> view of this model still updates the session.

Again try in your controller…

HTH,

Long  
www.edgesoft.ca
