[RESOLVED] How Do You Read/Write Mult-value cookies in Javascript?
Good morning gang.
I'm having a hard time figuring out how to do this. I'm trying to write a cookie that has a name for example "Order" in which this "Order" cookie will have values associated with it for example:Color, Location, Type and Style. I see that this is pretty simple to do in .net but it's during a jquery grid row select event that I have the row's values available for processing. In other words in a bit of jquery code is where I am able to deal with the data to be passed around in the web app. If I could get that data out to a .net routine that would be ideal but to me it looks like I can't do that. So anyway does anyone have a little code snippet that they could share with me on how to do this? Please.
Re: How Do You Read/Write Mult-value cookies in Javascript?
Hello PeejAvery,
I also need to write such a cookie. Any chance you have the javacript function that writes the type of multi-valued cookie I described in my post? Especially can you help me out with the js that writes the mult-valued cookie that can easily be read by the Read js code you provided?
Re: How Do You Read/Write Mult-value cookies in Javascript?
Thanks PeejAvery,
I've seen this code at w3schools before. As-is the code creates a cookie in which the cookie will have a name and have one value asscoicated with it and not the multivalue type problem I wrote about that resemble this:"Order" in which this "Order" cookie will have values associated with it for example:Color, Location, Type and Style.
Or it could be that I'm a dum dum and don't see that the code as-is just needs a little tweaking. But I don't how to do get the code to support a multi value cookie. I don't undertand what the syntax needs to look like for a cookie that has more than one value.
Or It could be that I'm a super duper dum dum and don't see that the code as-is already supports the multi-value type cookie that I'm trying to do.
Re: How Do You Read/Write Mult-value cookies in Javascript?
Cookies only store as strings. So, if you want multiple datatypes or values in 1 cookie, you will have to make it an object and serialize it. Or you can make it character delimited data and just split it into an array.
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
Re: How Do You Read/Write Mult-value cookies in Javascript?
Oh ok, so the value will be have to be a put together thingie. I'll start trying to put this together and post my work of art when I'm done. Thanks for the direction. Stay tuned...
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'HttpCookie(cookie = Response.Cookies.Get("myCookieName"));
'HttpCookie(InlineAssignHelper(cookie, Response.Cookies.[Get]("myCookieName")))
'Label1.Text = Request.Cookies("TestCookie").Value
Dim rawRow As String = Request.Cookies("TestCookie").Value
'txtName.Text = Request.Cookies("TestCookie").Value
Dim rawRowSplit() As String = Split(rawRow, "|")
txtOrgID.Text = rawRowSplit(0)
txtName.Text = rawRowSplit(1)
txtStreet.Text = rawRowSplit(2)
End Sub
Bookmarks