关于苹果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。

posted on 2014-01-01 11:48  雾里寻踪  阅读(12429)  评论(2编辑  收藏  举报