Forum: Ruby on Rails reset_session when Ruby goes down

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
6a61cf8034cc984106c25778cc122592?d=identicon&s=25 Dinesh U. (udinesh)
on 2006-06-14 07:31

In my web application we have implemented the session and it works fine.
ie. it prompts for the userid/password when ever we give the URL by
opening a new IE window. i.e it goes through the session and see if the
:user_id is present in the session if not it prompts to log-in again.

But my problem is say if we "kill" the WebRICK abruptly by pressing ^C
and say my  browser window is open at some specific screen.  If i
refresh the page now it gives me Page not Found, which is fine, since
the server is down.

But when i restart the WebRICK server, i expect to prompt for the login
screen, but the behavioius is different, it does not prompt for login
page, it goes to the  current screen where it was before the server went

I guess what is happening is :user_id is still present in the Browser's
Session, since we did not explicity call a reset_session which we do in
case of log-out since the server was killed abruptly. and that i guess
is the reason when the server is re-started it still finds the :user_id
in the session and happily moves forward.

I'm using MYSQL DB..

Any way to solve the above problem? What i'm going wrong. bottom line
since the server went down, it should prompt to go to the log-in

This is my authorize method

def authorize
	if session[:user_id]
		@current_user = User.find(session[:user_id])
 	flash[:notice] = "Your Session is Expired, Please log into the
 		redirect_to(:controller => "login", :action => "login")

Thank You
choonkeat (Guest)
on 2006-06-14 08:50
(Received via mailing list)
> What i'm going wrong. bottom line
> since the server went down, it should prompt to go to the log-in
> screen..!!

On the contrary, I'd always felt that the current behavior of sessions
continuing to work after a restart was quite useful. :-)

Different ppl different needs I guess. In any case, you would probably
to clean out the sessions on start-up (append to config/environment.rb).

Depending on your config.action_controller.session_store setting, it may
deleting rows from sessions table or files from tmp/.
This topic is locked and can not be replied to.