First question, however stupid it sounds: are you sure you have
cookies enabled?
-----Original Message-----
From: garageman1130 [mailto:[EMAIL PROTECTED]
I am a student who needs to create a "bookStore" application that
will keep the value of the book last viewed title in a cookie, so
that on return to the site main page a label will welcome the uer
with "Last time you last viewed" & cookie value
I have made small dummy "set cookie" and another "retrieve cookie"
ASPX pages that will not work, much less the larger "application"
What am I doing wrong? I am working with windows 200 pro, IIS, and
ASP.NET Web Matrix.
Ted
code to set***
<%@ Page Language="VB" %>
<script runat="server">
Sub Page_Load(sender As Object, e As EventArgs)
Dim tedCookie As New HttpCookie("test_bookname")
tedCookie.Value = "works immediately"
Response.Cookies.Add(tedCookie)
Response.Cookies("test_bookname").Expires = Now.AddDays(1)
'Response.Cookies("test_bookname").Expires = Now.AddMonths(2)
Dim i As Integer
Dim output As String = ""
Dim aCookie As HttpCookie
For i = 0 to Request.Cookies.Count - 1
aCookie = Request.Cookies(i)
output &= "Cookie name = " & Server.HtmlEncode(aCookie.Name)
& "<br>"
output &= "Cookie value = " & Server.HtmlEncode(aCookie.Value)
& "<br>"
Next
Label2.Text = "We should see at least an ASP.NET_SessionId cookie
value and cookie name."
Label1.Text = output
End Sub
</script>
<html>
<head>
</head>
<body>
<form runat="server">
<p>
<asp:Label id="Label2" runat="server" width="618px" font-
bold="True">Label</asp:Label>
</p>
<p>
</p>
<p>
<asp:Label id="Label1" runat="server">Label</asp:Label>
</p>
</form>
</body>
</html>
**end
***code to retreive in another ASPX PAGE
<%@ Page Language="VB" %>
<script runat="server">
' Insert page code here
'
Sub Page_Load(sender As Object, e As EventArgs)
If Request.Cookies("test_bookname") Is Nothing Then
Label1.Text = "oops, even though in 'cookieset.aspx' I set
the Expires property to 1 day later??? where is Cookie name =
test_bookname below?"
else
Label1.Text = Server.HtmlEncode(Request.Cookies
("test_bookname").Value)
Label2.Text = Request.Cookies("test_bookname").Value
End If
Dim i As Integer
Dim output As String = ""
Dim aCookie As HttpCookie
For i = 0 to Request.Cookies.Count - 1
aCookie = Request.Cookies(i)
output &= "Cookie name = " & Server.HtmlEncode(aCookie.Name)
& "<br>"
output &= "Cookie value = " & Server.HtmlEncode
(aCookie.Value) & "<br>"
Next
Label3.Text = "Cookie data from looping Code: " & "<br>" &
output
Label4.text = " Label4: seems I get a new session ID every
refresh, and between pages in the same application folder??"
End Sub
</script>
<html>
<head>
</head>
<body>
<form runat="server">
<p>
<asp:Label id="Label1" runat="server" forecolor="Red"
font-bold="True">Label1</asp:Label>
</p>
<p>
</p>
<p>
</p>
<p>
<asp:Label id="Label2" runat="server"
width="414px">Label2</asp:Label>
</p>
<p>
</p>
<p>
<asp:Label id="Label3" runat="server" width="551px"
height="48px">Label3</asp:Label>
</p>
<p>
</p>
<p>
<asp:Label id="Label4" runat="server" forecolor="Blue"
font-bold="True">Label</asp:Label>
</p>
<!-- Insert content here -->
</form>
</body>
</html>
Yahoo! Groups Links
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/