how do I do cookies?

N

Neil

Hi,

Although an experienced ASP programmer, I can't work out how to do cookies
in ASP.NET

I need (for instance) to set a cookie for a UserID once a client has logged
on to my site, so that other pages can check this as and when required.

I imagine that there are other ways of doing this, but I would still like to
be able to use cookies as well.

Any advice appreciated - cheers!

NEIL
 
M

Mark Rae

Although an experienced ASP programmer, I can't work out how to do cookies
in ASP.NET

I need (for instance) to set a cookie for a UserID once a client has
logged on to my site, so that other pages can check this as and when
required.

I imagine that there are other ways of doing this, but I would still like
to be able to use cookies as well.

Any advice appreciated - cheers!

1) Launch your internet browser (e.g. IE, FireFox, Opera, Netscape, Mozilla
etc)

2) Navigate to http://www.google.com

3) Enter the text below in the box:

"ASP.NET" cookies

4) Hit the button
 
G

Guest

Easy way:

Response.Cookies["userId"]=userId;
Response.Cookies["userId"].Expires=DateTime.Now(AddDays(365));

int userId=(int)Request.Cookies["userId"];

Does that help?
Peter
 

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

Top