Cookies

i get a undefined method/variable when i try use cookies in my rails
rhtml files? any idea?

<%= cookies[:user] %>

gives an error

On 6/27/06, raj kapila [email protected] wrote:

i get a undefined method/variable when i try use cookies in my rails
rhtml files? any idea?

<%= cookies[:user] %>

gives an error

“cookies” is a controller method. Call it in your controller and set
a variable for your view to use.

Also, given your example, I think you’re heading down the road to a
disaster. If you’re really storing a user id in a cookie, that’s
kind-of odd. If you’re actually trusting this value, that’s going to
be big trouble when a user decides to change the user id in his cookie
and send it to your server.

– James

<%= cookies[:user] %>

gives an error

“cookies” is a controller method. Call it in your controller and set
a variable for your view to use.

Also, given your example, I think you’re heading down the road to a
disaster. If you’re really storing a user id in a cookie, that’s
kind-of odd. If you’re actually trusting this value, that’s going to
be big trouble when a user decides to change the user id in his cookie
and send it to your server.

– James

so should i just rails sessions?

On 6/27/06, raj kapila [email protected] wrote:

“cookies” is a controller method. Call it in your controller and set
a variable for your view to use.

Also, given your example, I think you’re heading down the road to a
disaster. If you’re really storing a user id in a cookie, that’s
kind-of odd. If you’re actually trusting this value, that’s going to
be big trouble when a user decides to change the user id in his cookie
and send it to your server.

so should i just rails sessions?

Yes. For one thing, the hard work has already been done for you.
There are also a number of 3rd party extensions / plugins for managing
authentication / authorization depending on the level of complexity
that you need.

If you haven’t already, you should most definitely read “Agile Web
Development With Rails” (2nd edition beta if you have a choice). The
book “Rails Recipes” has a good section on creating your own login /
role system from scratch (recipes 31 + 32).

– James

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs