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

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -