Cookies not being sent back and forth properly in

2020-02-27 03:47发布

First off, I'm not sure whether this is a problem in Opera 12.01 or not, but the problem only occurs in Opera. I've tested in FF14, Chrome 21, Safari 5 (Windows) and Safari Mac and Webkit browsers on Android and iPhone.

My application runs on the trigger.io forge platform and uses a proxy to route requests from the web application to the service. The proxy simply forwards the requests and cookies along and this works as expected in most of the browsers.

After inspecting the request in dragonfly, I noticed that the server sends the proper headers in the response, but Opera seems to be ignoring setting the values. I'm wondering whether this is due to some misconfigured path value for the cookie. I've attached screenshots of 2 requests in Firefox and Opera.

As you can see in the screens, FF sees the cookie headers and sets them appropriately, but Opera does not.

Firefox Request

Firefox request

Opera request 1 Screen

Opera request 1

Opera Request 2 Screen

Opera Request 2

I haven't included the code from the proxy that does the request forwarding, so please let me know if you need that to gain some insight. On the service end, I'm running PHP and Codeigniter. Please let me know if I need to add any more info here on my environment, thanks.

UPDATE : This issue occurs even in my production environment which does not use a custom TLD. Other sites that use cookies work fine and cookies are enabled.

3条回答
迷人小祖宗
2楼-- · 2020-02-27 04:05

Double quotes are formally illegal in a cookie value. If you escape them as %22 it will work.

查看更多
萌系小妹纸
3楼-- · 2020-02-27 04:24

Have you checked if this is an issue with cookie domains ? I'm assuming you're using Javascript to set/read the cookies ? In any case there are 4 cookie domain issues that you might want to check (I know I've had these issue with an old FF version):

1 - check for illegal cookie characters: allowed cookie characters you might not be allowed to use '-' or '=' in the cookie name, and you shouldn't use non-ASCII characters in cookies at all. A base64 encode might deal with this.

2 - check that the domain on which you set your cookie (via javascript code or any other way) is identical to the domain on which the code is executed.

3 - check that the cookie domain is not localhost; see if you can test setting the cookie from a remote domain

4 - if you're using JS to set your cookies, try testing if you can set the cookie with a CGI in your browser to make sure it's not a browser issue. If it works which it should, see if you can read the cookie using JS (as opposed to setting it).

Let me know how this goes in the comments, I've dealt with similar issues a number of times and depending on what you get with these checks, I'm pretty sure I can help you fix the issue.

查看更多
一夜七次
4楼-- · 2020-02-27 04:24

Looking at those Opera screenshots, they seem to be AJAX / XHR requests which are processed within the same second. Is it possible that Javascript is triggering both of those requests "simultaneously", so the response from the "first" is not arriving before the request for the "second" is constructed - and therefore the cookies have not yet been set?

I'm not familiar with the technologies/toolkits you're using, so don't know if these are stock code or part of your custom application.

查看更多
登录 后发表回答