Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Cookies. Simple Question. Thank You.

Reply
Thread Tools

Cookies. Simple Question. Thank You.

 
 
Shapper
Guest
Posts: n/a
 
      04-29-2005
Hello,

I need to know how to do 2 things:
1. CREATE a NEW cookie with 2 values: "password" and "user".
2. APPEND 2 new values to an ALLREADY EXISTING cookie.

I created a code which is working:
Dim cookie As HttpCookie = New HttpCookie("MyCookie")
cookie.Values.Add("culture", "pt-PT")
cookie.Expires = #01/01/2010#
Response.Cookies.Add(cookie)

I don't understand what code changes should I implement from (1) to (2).

Can someone help me?

Thank You,
Miguel


 
Reply With Quote
 
 
 
 
David Young
Guest
Posts: n/a
 
      04-29-2005
1.) Create Cookie with 2 values:

HttpCookie cookie = new HttpCookie("myCookie");
cookie["userid"] = "myid";
cookie["password"] = "pwd";
Request.Cookies.Add(cookie);

*Note. Storing a password in a cookie is generally not a good idea.
However, there may be times when this does need to be done. If you need to
strore the users password in a cookie, then you should encrypt (hash) the
password before storing it in the cookie or encrypt the entire cookie. Just
a suggestion If you need help with the encryption aspect, shoot me an
email.

2) Add values to an existing cookie

HttpCookie cookie = Request.Cookies["myCookie"];
cookie["newKey"] = "newValue";
Request.Cookies.Add(cookie);


Dave
dmy75252[removethis]@yahoo.com


"Shapper" <mdmoura*NOSPAM*@gmail.*DELETE2SEND*com> wrote in message
news:(E-Mail Removed)...
> Hello,
>
> I need to know how to do 2 things:
> 1. CREATE a NEW cookie with 2 values: "password" and "user".
> 2. APPEND 2 new values to an ALLREADY EXISTING cookie.
>
> I created a code which is working:
> Dim cookie As HttpCookie = New HttpCookie("MyCookie")
> cookie.Values.Add("culture", "pt-PT")
> cookie.Expires = #01/01/2010#
> Response.Cookies.Add(cookie)
>
> I don't understand what code changes should I implement from (1) to (2).
>
> Can someone help me?
>
> Thank You,
> Miguel
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Simple SQL question. Can you check what am i doing wrong? Thank You. Miguel Dias Moura ASP .Net 1 06-18-2004 09:33 AM
Thank you, I got it running again :D Christian Dornes Firefox 0 12-04-2003 06:59 PM
Thank You CJ, Thank Mike! mytho Computer Support 7 11-23-2003 06:50 AM
Thank you... Troll Perl 1 09-07-2003 04:05 PM



Advertisments