1

I have a program that writes in the cookie on a page, the redirect,

SetCookie(key,value);
Response.Redirect("SecondPage.aspx");

and tries to read the cookie on the second page.

var value = GetCookie(key);

As simple as that! It works fine on IE/FF/Chrome, but not in Apple's Safari!

This is how the cookie value looks line in IE/FF/Chrome:

flyerName=1111+test+road%2c+LS%2c+MO&flyerPersonId=1241BST34&flyerTemplate=Vertical.pdf&flyerListing=6666&flyerOrg=TESTORG

and in Safari:

flyerName=1111+test+road

apparently Safari has truncated the string after %2C which is comma(,) in ascii table!

P.S. I've seen this post, but it didn't help me.

Community
  • 1
  • 1
Amir
  • 9,577
  • 11
  • 41
  • 58

2 Answers2

2

Problem solved! Before saving cookie, do a Server.UrlEncode(strValue) and when retrieving that used a Server.UrlDecode(c.Values.Item(strKey))

Apparently Safari cannot handle the "," and ";" correctly in cookie value.

Amir
  • 9,577
  • 11
  • 41
  • 58
0

Try this

Responce.cookie["PageUrl"].value=your value;
Responce.cookie["PageUrl"].Path="/";

now you can access this cookie throught out you application;

Sagar Hirapara
  • 1,677
  • 13
  • 24
  • Thx, it didn't work, problem is not with where to store cookie data, it's with storing "," without truncating rest of the cookie. – Amir Apr 30 '13 at 17:40