Asp.net 2.0 - Cookies

G

Gil Paz

Looks like a very simple question, but I don't find the answer.
I use ASP.net 2.0 VB, I would like to check if a cookie exist on the clients
computer's and if not to create.

In order to create a cookie I write:

Dim Cookie As HttpCookie = New HttpCookie("UserID")
Cookie.Values.Add("SessionID", Session.SessionID)
Cookie.Expires = DateTime.Now.AddYears(30)
Response.Cookies.Add(Cookie)

But I don't know how to in the begining if the cookie exist or not.
Please, I need you help !
 
C

clintonG

// Use the Request object to determine the status of the cookie
if (Request.Cookies["cookieName"] != null)
// do something
else
// create the cookie
 
V

vMike

Gil Paz said:
Looks like a very simple question, but I don't find the answer.
I use ASP.net 2.0 VB, I would like to check if a cookie exist on the clients
computer's and if not to create.

In order to create a cookie I write:

Dim Cookie As HttpCookie = New HttpCookie("UserID")
Cookie.Values.Add("SessionID", Session.SessionID)
Cookie.Expires = DateTime.Now.AddYears(30)
Response.Cookies.Add(Cookie)

But I don't know how to in the begining if the cookie exist or not.
Please, I need you help !

If Request.Cookies("UserID") Is Nothing
 

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

Similar Threads


Members online

No members online now.

Forum statistics

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

Latest Threads

Top