Link to home
Start Free TrialLog in
Avatar of scm0sml
scm0sml

asked on

checking for an existing cookie

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
ASKER CERTIFIED SOLUTION
Avatar of kaufmed
kaufmed
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial