Ruby Sinatra Cookies -


i having issue setting persistent cookies in sinatra:

i have 2 routes set same key:

response.set_cookie('user_id',                     { :value => params[:user_id],                        :expires => time.now + (60 * 60 * 24 * 30),                        :path => '/'  }) 

the difference between 2 routes 1 post , other get. in both cases set path of cookies '/'.

when try retrieve cookie value in route:

user_id = cookies[:user_id] 

i cookie set via post route, if later overwrite using route.

i haven't been able find documentation aspect of sinatra, appreciated.

you must use

user_id = request.cookies[:user_id] 

Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -