Jonathan
Jonathan

Reputation: 11494

Check for existing Cookie with Rails 3 or Javascript / jQuery

I have a simple login which starts off with a disabled login button unless the username and password are filled (this check is done by jQuery and removes the disabled attribute if filled).

The problem I am now having is checking to see if the fields are pre-filled by an existing cookie, if they are, then the pre-emptive disabled attribute should not be applied. I was thinking of doing this through Rails but perhaps it can also be done via Javascript / jQuery.

So the question in short could be: how do I check for a cookie in Rails 3.2.* or jQuery?

Upvotes: 0

Views: 2083

Answers (1)

Ibrahim Muhammad
Ibrahim Muhammad

Reputation: 2896

In the controller you can just say cookies["key"] to get the value of something stored in a cookie.

Upvotes: 3

Related Questions