Skip to main content

  | मौसम…

411 समाचार
Public archive edition · Attributed source reporting with original dates · AI drafts are excluded

411 REFERENCE · Wikibooks

Ruby on Rails/ActionController/Cookies

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

Cookies Of course you can work with cookies inside your Rails application. This is, again very similar to working with parameters or sessions. Consider the following example: def index #here we want to store the user name, if the user checked the "Remember me" checkbox with HTML attribute name="remember_me" #we have already looked up the user and stored its object inside the object-variable "@user" if params[:remember_me] cookies[:commenter_name] = @user.name else # Delete cookie for the commenter's name cookie, if any cookies.delete(:commenter_name) end end