Sessions

I am using activerecord for saving my sessions.

I have added a user_id field to my sessions table

how can i save the user id to this table once the user logs on for the
frist time?

CGI::Session::ActiveRecordStore::Session.user_id = current_user.id

i am trying the above line but its not working. Any ideas?

why do you add a user_id column? thats not the way activeRecordStore
works …

all data that you put in a session gets serialized and saved in one
column.

when the user logs on, you would just do:

session[:user_id] = @user.id

WITHOUT having a user_id column in the sessions table. Rails handles it
for you.

Thorsten L wrote:

why do you add a user_id column? thats not the way activeRecordStore
works …

all data that you put in a session gets serialized and saved in one
column.

when the user logs on, you would just do:

session[:user_id] = @user.id

WITHOUT having a user_id column in the sessions table. Rails handles it
for you.

ok that works but when i run

def isonline
for current_session in
CGI::Session::ActiveRecordStore::Session.find(:all)
if current_session[:user_id] == self.id
return true
end
end
return false
end

i get false back everytime even when i know the user is online

don’t know if you have read this article but it should answer your
question

http://habtm.com/articles/2005/12/15/whos-online

Chris