关于苹果safari浏览器登陆时Cookie无法保存的问题


前段时间,修改了登录处理后给到客户端浏览器Cookie的内容,新增了一个姓名的value,发现safari不能保存该Cookie的内容,同时Chrome、firefox、ie等浏览器都能正常的访问,直接人就崩溃了。

找了好多的资料,国内的,基本都是牛头不对马嘴,根本不是这回事。

最后直接google国外的资料,终于在第n页看到了一个帖子:http://stackoverflow.com/questions/5327341/strange-problem-with-cookies-in-safari-and-asp-net。

Bingou,找到问题所在了:Safari will not set cookies with non-ASCII characters in their value and other browsers can be unpredictable in how they display non-ASCII characters. As semi-colon is also not allowed in cookie values for any browser I would recommend using UrlEncode/UrlDecode.

就是非ASCII码的汉字,是不被认可的字符。那么只好对汉字进行了UrlEncode,读取的时候再来UrlDecode。

测试结果:OK。


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM