Cookies 
Author Message
 Cookies

Using Windows 2000, .Net Enterprise (C#).

I have been unsuccessfully trying to read and write
cookies.

Here is what I have attempted so far:

Reading:

HttpCookie portalCookie = Request.Cookies["county.portal"];
string name = portalCookie.Name;

This is a valid cookie that I can see in my path, but I
constantly get a null value.  Do I have to explicitly
declare the path in order to read it?

Writing:

HttpCookie userCookie = new HttpCookie("newcookie");
userCookie.Values.Add("userId", "Fred.Flintstone");
userCookie.Values.Add("department", "mental");
userCookie.Values.Add("Date", DateTime.Today.ToString());
Response.SetCookie(userCookie);

This does not create a cookie on my machine, but I can
read it during the session.

Any assistance greatly appreciated.



Sat, 20 Nov 2004 03:43:28 GMT  
 Cookies
You need to set the expiration for the cookie.

-glenn-


Quote:
> Using Windows 2000, .Net Enterprise (C#).

> I have been unsuccessfully trying to read and write
> cookies.

> Here is what I have attempted so far:

> Reading:

> HttpCookie portalCookie = Request.Cookies["county.portal"];
> string name = portalCookie.Name;

> This is a valid cookie that I can see in my path, but I
> constantly get a null value.  Do I have to explicitly
> declare the path in order to read it?

> Writing:

> HttpCookie userCookie = new HttpCookie("newcookie");
> userCookie.Values.Add("userId", "Fred.Flintstone");
> userCookie.Values.Add("department", "mental");
> userCookie.Values.Add("Date", DateTime.Today.ToString());
> Response.SetCookie(userCookie);

> This does not create a cookie on my machine, but I can
> read it during the session.

> Any assistance greatly appreciated.



Sat, 20 Nov 2004 04:08:29 GMT  
 Cookies
Thanks, glenn, that solves writing!

Still cannot read - hmmm.

Any other suggestions?

Thanks again,

jon

Quote:
>-----Original Message-----
>You need to set the expiration for the cookie.

>-glenn-



>> Using Windows 2000, .Net Enterprise (C#).

>> I have been unsuccessfully trying to read and write
>> cookies.

>> Here is what I have attempted so far:

>> Reading:

>> HttpCookie portalCookie = Request.Cookies
["county.portal"];
>> string name = portalCookie.Name;

>> This is a valid cookie that I can see in my path, but I
>> constantly get a null value.  Do I have to explicitly
>> declare the path in order to read it?

>> Writing:

>> HttpCookie userCookie = new HttpCookie("newcookie");
>> userCookie.Values.Add("userId", "Fred.Flintstone");
>> userCookie.Values.Add("department", "mental");
>> userCookie.Values.Add("Date", DateTime.Today.ToString
());
>> Response.SetCookie(userCookie);

>> This does not create a cookie on my machine, but I can
>> read it during the session.

>> Any assistance greatly appreciated.

>.



Sat, 20 Nov 2004 04:34:28 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. request cookie or response cookie?

2. should I use cookie.Value =, or cookie.Values.Add() ?

3. Update cookie value

4. Cookies in a Class

5. Cookies

6. web page fetching and cookies

7. Cookies Help Plz

8. .NET Lightning Connection Speeds & Fortune Cookies

9. Connection Points and cookies

10. Cookies in C#

11. cookies and WebPost

12. Retrieving and setting cookies from an instantiated browser

 

 
Powered by phpBB® Forum Software