Forum: Ruby on Rails What am I missing?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Al E. (Guest)
on 2006-05-17 20:41
There's got to be a simple answer to this...

  def logout
    reset_session
    flash[:notice] = "Logged out"
    redirect_to :action => 'index'
  end

The flash never shows up, and doesn't seem to be in the new session.

--Al Evans
Tom D. (Guest)
on 2006-05-17 20:47
(Received via mailing list)
I ran into this one too.  The problem is since you reset the session,
and the flash is stored in the session there is no way to access it
again, as the session key is destroyed.

My workaround was to just pass that info in the url as follows:

redirect_to login_url(:expired => @session_expired)

And in my case, I will display how long ago the session expired.

Tom

On 5/17/06, Al Evans <removed_email_address@domain.invalid> wrote:
> --Al Evans
>
> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> Rails mailing list
> removed_email_address@domain.invalid
> http://lists.rubyonrails.org/mailman/listinfo/rails
>


--
Tom D.

http://blog.atomgiant.com
http://gifthat.com
Gregory S. (Guest)
on 2006-05-17 20:53
(Received via mailing list)
On Wed, May 17, 2006 at 06:41:07PM +0200, Al Evans wrote:
} There's got to be a simple answer to this...
}
}   def logout
}     reset_session
}     flash[:notice] = "Logged out"
}     redirect_to :action => 'index'
}   end
}
} The flash never shows up, and doesn't seem to be in the new session.

The session is tied to a cookie on the client browser. When you call
reset_session, you get rid of the session connected to that cookie. When
a
a page is rendered, the cookie is updated, but you are redirecting. My
suspicion is that either rails does not send the new cookie with a 3xx
redirect response or the client browser ignores a cookie in a 3xx
response.
Once the index action is being rendered, it is already too late.

} --Al Evans
--Greg
Al E. (Guest)
on 2006-05-18 00:29
Tom D. wrote:

> My workaround was to just pass that info in the url as follows:
>
> redirect_to login_url(:expired => @session_expired)

Thanks. That works fine, except for ending up with the message appended
to the URL. I guess I can't have everything:-)

Thank you, too, Greg, for the explanation.

--Al Evans
This topic is locked and can not be replied to.