开发者

Rails: Cookieoverflow. When does Rails use cookies without letting me know?

开发者 https://www.devze.com 2023-03-05 15:23 出处:网络
without posting my exact problem with a Cookieoverflow, I want to ask, what can cause a CookieOverflow?

without posting my exact problem with a Cookieoverflow, I want to ask, what can cause a CookieOverflow?

I have only one session-var session[:user] = @user, which is the current logged in account.

In my whole app I have no problems with a CookieOverflow, but in one action, where I am not using the session- or cookies-var, I get a CookieOverflow.

So without inspecting my problem in detail, what can cause a CookieOverflow as well, when it is not the false use of session[] and cookies[]?

I really don't think that this session-var for the user is really the problem... I commented it out and still get the error.

So the question is exactly, "In what cases does Rails use cookies, without my explicit call of it? / When does Rails use cookies, wiht开发者_StackOverflow中文版out letting me know of it?"

Yours,

Joern


@user is an instance of a User model, I assume?

A quick google search suggests storing models in cookies is a bad idea: http://www.quarkruby.com/2007/10/21/sessions-and-cookies-in-ruby-on-rails#slimitations

The session cookie size is pretty small (~4kb), could it be that the @user instance is bigger than that? Perhaps you could just store @user.id in the session?

Also, the error may appear when you are making changes to the object referenced by @user elsewhere in the model; if the session cookie is tracking this object, then that could push it over the 4kb limit.

Just some thoughts - happy to be corrected by Those Of Great Reputation.


you cant store more than 4k data in cookies.i think your @user variables size is more than 4k.that's why error is raised

0

精彩评论

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