Rails3 / Sessions / Active_Record_Store / Signout & # 8594; How to delete a cookie and an entry in the Sessions table?

Using active_record_store to store information related to my users' sessions and a great time with how simple it is, but also to find that it is so simple that I do not spend time to figure it out.

I recently discovered that when users exit my site, nothing in the Sessions table is deleted, so I quickly put together a fairly large session table.

I would like to do this: Delete the entry in the Sessions table when the user logs out and deletes the cookie on the user's computer. What do I need to add to my program to execute this command?

At the moment, all I'm doing is clearing the user ID from the session data, which is clearly not enough. I thought I could just delete the entry from the sessions by calling the destroy () method on the ActiveRecord object, but I don't have a session ID. (Maybe I just don't know how to get this?)

+4
source share
3 answers

I am new to rails, but I suggest you try the following:

rake db:sessions:clear 
+2
source

Just because this is the best google answer when searching for "rails active_record_store clear table", here is the answer on how to clear the session table: fooobar.com/questions/287791 / ...

0
source
  session[:user_id] = nil session[:username]= nil flash[:notice]= "You have been Logged out" redirect_to(:action => "login") 
-1
source

Source: https://habr.com/ru/post/1338180/


All Articles