473,799 Members | 2,711 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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("MyC ookie")
cookie.Values.A dd("culture", "pt-PT")
cookie.Expires = #01/01/2010#
Response.Cookie s.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 1036
1.) Create Cookie with 2 values:

HttpCookie cookie = new HttpCookie("myC ookie");
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.*DELETE 2SEND*com> wrote in message
news:e9******** ******@TK2MSFTN GP10.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("MyC ookie")
cookie.Values.A dd("culture", "pt-PT")
cookie.Expires = #01/01/2010#
Response.Cookie s.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
3886
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 new site I goto seems to prompt me to store their cookie. The other is Pocket IE on Pocket PC 2002, with the cookies set to 'enabled'. My problem is that the cookies dont seem to be being written with my ASP. I dont get the prompt to store...
9
2540
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
3061
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 cookie (say Response.Cookies ("TEST")) and you have a query string variable &test=x or &Test=x and you get Request.QueryString to parse the query string, the cookie that gets dropped matches the case of the query string, not what your code says. ...
0
994
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 cookies" I set IE's Local Intranet security setting to High.
8
2345
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> 6> Response.Cookies("test").value = Now.AddDays(10)
3
4113
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 storing data in the cache object, in a viewstate and in a Session. I can say Cache("MyData")=objDataSet as well as
2
1186
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") cookie.Values.Add("cid", Session("sid")) cookie.Values.Add("ckeywords",Session("skeywords")) cookie.Values.Add("ccampaignno",Session("scampaignno")) cookie.Values.Add("cadgroup",Session("sadgroup"))
16
11056
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 read documents on the CookieCollection property of HttpWebRequest. Currently, I have the functionality in my code to be able to accept cookies, and return them upon a new HttpWebRequest; however, upon further inspection of the returning...
5
5568
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 Explorer. I would appreciate any help anyone can offer, please. First, consider the following very simple JavaScript function: function CookiesEnabled() { SetCookie( "testcookie", "testcookie" ) ; var bCookiesEnabled = ( GetCookie(...
0
9550
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10269
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10248
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10032
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9085
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6811
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5469
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5597
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3764
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.