Simple question about cookie:

  • Thread starter Ivan Demkovitch
  • Start date
I

Ivan Demkovitch

Hi!

From what I understand cookies could be persisted or in-memory.

I need to set second one...

This code:
Response.Cookies["phpbb_data"].Value = Server.UrlEncode(phpC);
Response.Cookies["phpbb_data"].Path = "/";
Response.Cookies["phpbb_data"].Expires = DateTime.Now.AddMinutes(1);

would place cookie on HDD regardless of "Expires" property (even if I don't
set it)

In MSDN I found object Cookie with property Discard. This is what I need,
but the one I use is HttpCookie.

How do I set this in-memory cookie???

Thanks!
 
K

Kevin Spencer

If you create a cookie and don't set an expiration, it will expire as soon
as the browser session ends.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
I

Ivan Demkovitch

It doesn't. It show
ExpirationDate 1/1/0001 12:00:00 AM





Kevin Spencer said:
If you create a cookie and don't set an expiration, it will expire as soon
as the browser session ends.

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

Ivan Demkovitch said:
Hi!

From what I understand cookies could be persisted or in-memory.

I need to set second one...

This code:
Response.Cookies["phpbb_data"].Value = Server.UrlEncode(phpC);
Response.Cookies["phpbb_data"].Path = "/";
Response.Cookies["phpbb_data"].Expires = DateTime.Now.AddMinutes(1);

would place cookie on HDD regardless of "Expires" property (even if I don't
set it)

In MSDN I found object Cookie with property Discard. This is what I need,
but the one I use is HttpCookie.

How do I set this in-memory cookie???

Thanks!
 
B

bruce barker

how the browser remembers a cookie is browser dependant. IE always writes
the cookie to disk even if its a session cookie (no expir date)

cookies are just header records on a web request or response. when the
browser sees a cookier header in a response, it stores it for future use.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top