开发者

Cookies not being saved right away with Rails app

I have a Rails app that is storing some user information in a cookie, and that information isn't being stored as soon as I would like. A client that is performing five requests in a row from a single page has an empty cookie until the page has completely loaded, and then for the future, the cookie is populated. It is behaving as if the client doesn't actually commit the cookies until the page is loaded. This is true using multiple browsers, so it doesn't appear to be purely a quirk of any one particular browser. Is there any way to commit those, or am I going to hav开发者_运维百科e to find another workaround?


Could you explain in more detail what you're doing to generate five rails requests in the context of a single page load? Can you guarantee the order in which these requests will arrive at the web server?

I'm guessing that cookies aren't going to be the optimal way of accomplishing what you're trying to do.


The cookie is set on the visitor's browser only after the response is returned, so you won't find the value in the cookie during the request.

If you set cookies[:some_key] to a value when you're processing the request on a Rails controller, can't you just look up the value you just set later on? How exactly are you setting and looking up the cookie value?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜