I have a Rails app with devise integrated. I'm using the Cookie Store session. I need to s开发者_JS百科tore some data in the session everytime someone signs in, Eg. their user id. How can i do so with Devise?
May be there is some elegant way where i just dont need to do that and could access it with Devise itself.?
Thanks!
You can use the "session" variable inside the controllers. Something like
session[:some_value] = "some_value"
Also Devise already has the user_id stored in the session.current_user
helper method can be used here.
Also make sure you read this, it has details about the what to store in session or not. http://guides.rubyonrails.org/security.html
Also cookie session store is usually only 4k in size, so you can't store a lot of data in them or your app will start to error out.
精彩评论