473,406 Members | 2,698 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Cookies. Simple Question. Thank You.

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
Nov 19 '05 #1
1 1025
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:e9**************@TK2MSFTNGP10.phx.gbl...
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

Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Brian Burgess | last post by:
Hi all, Anyone know of any special issues with storing cookies with ASP? I'm trying this with two browsers: One is IE 6.0 with cookies set to 'prompt'. This has been working properly as any...
9
by: | last post by:
Is it possible for a user to enable permanent cookies but disable session cookies.....this seems like a contradition yet this is what I appear to be reading in online articles?
6
by: Mark | last post by:
Hi... I've come across some weird bug with Response.Cookies. Or maybe it will be called "by design" but for the life of me I can't figure out what purpose it would serve. If you're setting a...
0
by: Framework fan | last post by:
Hello. I am having difficulty testing when the user selects "Block all cookies" inside IE. My trouble is that my test cookie never gets blocked. I set IE's privacy level to "Block all...
8
by: CDARS | last post by:
Hi all, I have a confusing question on ASP.NET cookies usage: 1> Response.Cookies("test").value = Now 2> Response.Write(Request.Cookies("test").value) 3> 4> Response.write("<hr>") 5>...
3
by: Alex Nitulescu | last post by:
Sorry, I'm really confused - I'm only at the middle of my book and already I can count 4 methods to store values. Yes, I know that cookies can not store much, but what is the difference between...
2
by: William | last post by:
I'm new to ASPX. In my .aspx page I set multiple cookies from the session variables to the "visitor" container: dim cookie as HttpCookie cookie=new HttpCookie("visitor")...
16
by: Cheung, Jeffrey Jing-Yen | last post by:
I have a windows form application that generates a request, downloads an image, and waits the user to enter in login info. Unfortunately, this image is dynamic and based on session data. I have...
5
by: jheines | last post by:
I am trying to explain how cookies and sessions work in a class I teach, but I have hit a wall when it comes to the interaction between cookies and the state of the privacy settings in Internet...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.