cookie result too long

D

D.

Hi,

I defined some cookies in order to pass values between pages in my
application.
The problem is that when i request them with:
cookie = Request.Cookies("mycookie")
x = cookie.Value (suppose the value = 'yes')
Response.Write(x)

i get:
'mycookie=yes' instead of just 'yes'.

Any way to avoid the 'mycookie=' or i have to parse the whole string?
Thanks
D
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

The Value property only contains the value of the cookie, not the name
of the cookie.

How do you create the cookie? Do you use subkeys?
 
D

D.

Thanks for replying.
I created it like this:
<%@ Page Language="VB" %>
<script runat="server">
Sub page_load()
Dim cookie As HttpCookie
Dim lol As String
lol = "yes"

cookie = New HttpCookie("myookie")
cookie.Values.Add("mycookie", lol)
Response.Cookies.Add(cookie)
End Sub
</script>
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

As I suspected, you are adding a subkey to the cookie.

If you create a cookie like this:

cookie = New HttpCookie("myookie")
cookie.Values.Add("mycookie", lol)

you get the value using:

cookie.Values["mycookie"]


If you create a cookie like this:

cookie = New HttpCookie("myookie")
cookie.Value = lol

you get the value using:

cookie.Value
 
D

D.

Thanks again

Göran Andersson said:
As I suspected, you are adding a subkey to the cookie.

If you create a cookie like this:

cookie = New HttpCookie("myookie")
cookie.Values.Add("mycookie", lol)

you get the value using:

cookie.Values["mycookie"]


If you create a cookie like this:

cookie = New HttpCookie("myookie")
cookie.Value = lol

you get the value using:

cookie.Value


D. said:
Thanks for replying.
I created it like this:
<%@ Page Language="VB" %>
<script runat="server">
Sub page_load()
Dim cookie As HttpCookie
Dim lol As String
lol = "yes"

cookie = New HttpCookie("myookie")
cookie.Values.Add("mycookie", lol)
Response.Cookies.Add(cookie)
End Sub
</script>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top