前段時間,修改了登錄處理后給到客戶端瀏覽器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。