evaleah Posted May 20, 2003 Posted May 20, 2003 Hi Gang! I have a page where if a case is true I create a cookie. That part works great. However, I later want to retrieve the cookie but from a different page. When I call the cookie on the second page the value is back to "". Is this possible to do? I haven't set the expire property on the cookies on Page1. I wanted them to expire at the end of the session. Does that mean actually they are expiring when I navigate away from the page? The code to get the cookie back I am using on Page2 is: Dim ckMember As System.Web.HttpCookie = New HttpCookie("Member") If Not ckMember Is Nothing Then With ckMember If .Item("LastName") <> "" Then objLastName.Value = CStr(Trim(.Item("LastName"))) End If End With End If Thanks! Eva Quote
Liqdfire Posted May 20, 2003 Posted May 20, 2003 try using response and request.Cookies 'Use this to set cookie Response.Cookies("members").Value = <value> Response.Cookies("members").Path = "/" Response.Cookies("members").Expires = DateTime.Now.AddMinutes(1) it also looks like your putting a custom class in your cookie ?? Where did the .lastname come from ?? If you doing something like this Dim <variable> as Custom_Class_Person <valiable>.lastname = "yad yad" Cookie.Value = <variable> Then you would need to assign the calue of the cookie to a new instance of that custom class. Post your code where you make the cookie so I can look at it please. Quote
evaleah Posted May 20, 2003 Author Posted May 20, 2003 Actually, the syntax I am using is what MS is saying is more correct now than trying to use the old ASP style request and response objects. So "LastName" in this case is the key name of a cookie called "Member". Quote
Administrators PlausiblyDamp Posted May 20, 2003 Administrators Posted May 20, 2003 (edited) Syntax arguments aside you will still need to use the Response / Request objects to read and write the cookies to /from the browser. response.cookies.add(ckMember) 'Send cookie to browser ckMember = request.cookies("Member") 'Read cookie from browser ...or similar no MSDN installed at this PC;) Edited May 20, 2003 by PlausiblyDamp Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.