views:

226

answers:

1

I am reading "Agile Web Development with Rails, 3rd Edition" and confusing about session-cookie.

On page 474 it has a topic about cookie detection and they talk how to handler cookie-disabled user. And they come up with cookie session idea which from my understanding is a fake session that act as a cookie right ?

What I don’t understand are example codes they use before_filter :cookies_required and asking for request.cookies[session_key] is this the same as cookies variable or this is “fake cookie session” they talking about ?

And if it is “fake cookie session” what about use who have cookie-enabled ? I don’t see any code determine which user do and don’t have cookie?

p.s. don't know whether you can understand my question I'm very confusing right now.

Thanks,

A: 

Page 474 is a bit confusing. The cookie-based session, which is the default rails session store, stores the session_id as a cookie.You can also reset the session store - see bottom of p477-479.

The code examples your are asking about are listed in the book prior to the session topic. These are real cookies, just as would would set in javascript not sessions that are set as :cookie_store. They just happen to be saving the :session_key into the cookie.

The method cookies_test checks whether the user has cookies access.

daustin777