Forum: Ruby on Rails Switch user functionality

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.
F148ec0cad8ea241b1cfd80e7ec8a7df?d=identicon&s=25 int3rfear (Guest)
on 2006-12-26 07:11
(Received via mailing list)

I'm implementing a switch user function for an application, but I'm
having some trouble copying the session and I'm thinking there might be
a better way for this.

Currently my thinking is that when you switch a user, copy the current
users session and store it in a temporary variable. Log in the new user
and copy the temporary variable (with the old session) into a session
variable. Upon logout, check for this session variable and if present,
switch back.

I have all this working, but I can't copy the whole session (using the
variable "session"), but I have to copy each element of the session
instead. Obviously this does not work since if I add something else to
the session, I would have to modify this.

Another solution would be to setup a new session and just store and id
of the old session that I could just load back upon log out, but I'm
not quite sure of the implementation steps of this approach. Maybe
there is a good resource somewhere where I can find some good
information about how to manipulate session information and how it

Any ideas?

This topic is locked and can not be replied to.