how to store hash value in cookie with rails 3

I want to implement a remember me option for the login

therefore I want to store both username and hashed password to a cookie, and check it when the user come back to the site.

I tried to do

cookies[:user] = { :value => {:username => @user.username, :password =>
@user.hashed_password}, :expires => 1.month.from_now }

it's save the cookie, but I can't read its attributes

cookies[:user].username # doesn't work

by the way, is it the best solution to implement RememberMe?


Maybe this answer can help you

Better to use the session method for setting these sorts of things. Feel free to keep the session in a cookie by using the default :cookie_store setting in config/initializers/session_store.rb.

session[:user] = { :foo => { :bar => 'woot' } }

Then later...

session[:user][:foo][:bar] # => 'woot'

From what I have read, one can only store strings in cookies. In order to store other data structures one need to serialize the data, such as JSON or YAML.

And I guess Session object has this built-in

Need Your Help

Starting and stopping Selenium as a Grunt task

selenium gruntjs

I'd like to start Selenium as a Grunt task, run Cucumber, then stop Selenium after Cucumber exits.

Does a status transition from an issue status to the same status make sense in Redmine

workflow redmine

In Redmine you can define/update issue workflows in a status-matrix based way: