|
-
Jul 5th, 2007, 04:53 AM
#1
Thread Starter
Addicted Member
Error to retrieve data from cookies
Hi
I have created cookies in asp.net that is the below coding
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim newCookie As HttpCookie
newCookie = New HttpCookie("Books")
newCookie.Values.Add("Name", TextBox1.Text)
newCookie.Values.Add("FavBook", RadioButtonList1.SelectedItem.Text)
newCookie.Expires = #12/12/2008#
newCookie.Path = ("C:/Documents and Settings/ashok.I-WAVES.001/Cookies/")
Response.Cookies.Add(newCookie)
Label1.Text = "Cookies Created"
Button1.Visible = False
TextBox1.Visible = False
Label2.Visible = False
Label3.Visible = False
RadioButtonList1.Visible = False
End Sub
But I cant retrieve the data .The below code is used to retrieve data.Can u tell whts the error in that coding and what reason?
Protected Sub Retrieve_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Retrieve.Click
Try
Label1.Visible = False
Label4.Text = "Hello" & " " & Request.Cookies("Books")("Name") & "." &_ "We have a new book for you:"
If Request.Cookies("Books")("FavBook") = "C" Then
Label5.Text = "ABC C Book"
ElseIf Request.Cookies("Books")("FavBook") = "C#" Then
Label5.Text = "XYZ C Book"
Else
Label5.Text = "C++"
End If
Catch ex As Exception
End Try
End Sub
End Class
Thanks
Failing to plan is Planning to fail
-
Jul 5th, 2007, 05:30 AM
#2
Re: Error to retrieve data from cookies
Why are you specifying a path?
Compare your code to what's here to see if you're missing anything:
http://www.startvbdotnet.com/aspsite/forms/cookies.aspx
-
Jul 5th, 2007, 05:39 AM
#3
Thread Starter
Addicted Member
Re: Error to retrieve data from cookies
Hi mendhak,
Thanks for reply, Yes u found correctlt.Not different that code and u specified the link.I specified path because my system connected to server.The path is C:/Document and Settings/Administrator/Cookies/ they mentioned.
I check the path.But cookies are currently stored in my system
"C:/Documents and Settings/ashok.I-WAVES.001/Cookies" this path only.Is any problem to specify the path.I removed the path and checked it.The same think happened that previously i told.
Thanks
Failing to plan is Planning to fail
-
Jul 5th, 2007, 09:57 AM
#4
Re: Error to retrieve data from cookies
Next step. Try actually handling what you're catching.
Dim x as String = ex.Message
Then, step through your code and see what error is being caught, if any, and what the error message is.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|