I'm using the cookie JQuery plugin - - the way it tells your to use it in order to read a cookie is:
var isApprover = $.cookie("isApprover");
However my cookies are 2 part cookies:
Response.Cookies["userSettings"]["isApprover"]
I know I could go back through all my code and change the names, but I really don't want to do that, at this point. with this way, I can set all the userSettings to expire at once. I've tried it with square brackets (like above), including both parts and
only the identifying part, and it always shows as null
there are no two part cookie names. in the http header its
Set-Cookie: name=value;
when you use [][] with .net response object it just parses the value into multiple subkey/values. so you will need to parse the cookie value in javascript into subkey/values.
when you use [][] with .net response object it just parses the value into multiple subkey/values. so you will need to parse the cookie value in javascript into subkey/values.
In that case, how do I iterate through the subkey values of 'userSettings' and check to see the value of 'isApprover'?
elmoWatson
Participant
1054 Points
593 Posts
MVC JQuery, Cookies and 2 part cookie names
Jan 09, 2013 07:04 PM|LINK
I'm using the cookie JQuery plugin - - the way it tells your to use it in order to read a cookie is:
var isApprover = $.cookie("isApprover");However my cookies are 2 part cookies:
I know I could go back through all my code and change the names, but I really don't want to do that, at this point. with this way, I can set all the userSettings to expire at once. I've tried it with square brackets (like above), including both parts and only the identifying part, and it always shows as null
What's the syntax to read these kinds of cookies?
bruce (sqlwo...
All-Star
36852 Points
5446 Posts
Re: MVC JQuery, Cookies and 2 part cookie names
Jan 09, 2013 10:18 PM|LINK
there are no two part cookie names. in the http header its
Set-Cookie: name=value;
when you use [][] with .net response object it just parses the value into multiple subkey/values. so you will need to parse the cookie value in javascript into subkey/values.
elmoWatson
Participant
1054 Points
593 Posts
Re: MVC JQuery, Cookies and 2 part cookie names
Jan 10, 2013 01:28 PM|LINK
In that case, how do I iterate through the subkey values of 'userSettings' and check to see the value of 'isApprover'?
elmoWatson
Participant
1054 Points
593 Posts
Re: MVC JQuery, Cookies and 2 part cookie names
Jan 15, 2013 08:48 PM|LINK
never mind - I just used:
if (document.cookie.indexOf("isApprover=True") < 0) {....}