Cookies Expires is not working as per expectation

Viewed 259

I keep getting an error while using this line of code, I'm trying to let the cookie "myCookie" to expire when it's 12:00 am.

But I'm not sure why I'm unable to do this.

These are the errors:

If I use this,

Response.Cookies["myCookie"].Expires = DateTime.UtcNow.AddDays(1);

I got this:

Cannot apply indexing with [] to an expression of type 'IResponseCookies'

If I use this,

Response.Cookies("myCookie").Expires = DateTime.UtcNow.AddDays(1);

I got this:

Non-invocable member 'HttpResponse.Cookies' cannot be used like a method.

How to solve this?

1 Answers
Related