Simple question about cookie:

  • Thread starter Thread starter Ivan Demkovitch
  • Start date 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!
 
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.
 
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!
 
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.
 
Is there any way to read/write cookies "by hand" i.e. not using .NET object
but altering header directly?

I have following problem: I need to integrate PHP and ASP.NET portions of
site. I should write cookie that PHP will recognize and read/delete PHP set
cookie.

Right now I'm having really strange problems... Is it possible to have 2
cookies with the same name? When I place cookie thru asp.net php doesn't see
it and place another one and my debug page in asp.net show 2 identical
cookies...




bruce barker said:
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.



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!
 
Back
Top