Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clearing a Rails Session during Development

How do I clear the rails session so I can start with a fresh slate? I know I could just nullify each of the session variables with session[:my_var] = nil, but is there a rake task or something that knows how to restore the session data to its most basic form?

I'm using Spree and it stores a few properties in the session that I would like to clear out to see what's going on in the background, such as order_id, order_token, user_credentials_id, etc.

I'm using SQLite3

like image 580
Lance Avatar asked Feb 01 '10 07:02

Lance


People also ask

How do you delete a session in Ruby on Rails?

To clear the whole thing use the reset_session method in a controller. Resets the session by clearing out all the objects stored within and initializing a new session object. Good luck!

Where does rails store session data?

The session is only available in the controller and the view and can use one of a number of different storage mechanisms: ActionDispatch::Session::CookieStore - Stores everything on the client. ActionDispatch::Session::CacheStore - Stores the data in the Rails cache.

How are sessions stored in rails?

Rails uses ActionDispatch::Session::CookieStore as the default session storage. Learn more about other session storages in Action Controller Overview Guide. Rails CookieStore saves the session hash in a cookie on the client-side.


2 Answers

rake db:sessions:clear
like image 92
JRL Avatar answered Oct 24 '22 03:10

JRL


Check your session_store in your environment.rb file. You can use the "db:sessions:clear" only if it says active_record. In this case you are dumping your session in db.

Otherwise just clear your browser cookies.

like image 7
KCore Avatar answered Oct 24 '22 03:10

KCore