[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

checking for an existing cookie

Posted on 2011-10-31
1
Medium Priority
?
184 Views
Last Modified: 2012-05-12
Hi,

I have the following code:
   if (Response.Cookies["888"] == null)
            {

                aCookie = new HttpCookie("888");
                aCookie.Value = System.Guid.NewGuid().ToString();                
                aCookie.Expires = DateTime.Now.AddDays(7);
                Response.Cookies.Add(aCookie);

I've just used a dummy name 888 for now but I'm trying to check to see if a cookie exists and if not create it.

However the code above always gets stepped over, even when the cookie shouldn't exist.

Am I doing the correct check?

Thanks
0
Comment
Question by:scm0sml
1 Comment
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 2000 total points
ID: 37057401
Shouldn't you be checking Request.Cookies rather than Response.Cookies? Add to the Response; read from the Request.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses
Course of the Month18 days, 14 hours left to enroll

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question