Dalibor
Dalibor

Reputation: 1572

C# Cookie value stored as name=value

This is what happens after a while, after my solution in Remembering Session in iframe with ASP.NET WebForms

It was working fine, but I don't know how this happens now:

        int utcOffset = 120; // added for example sake
        HttpCookie UTCOffset = new HttpCookie("UTCOffset");
        UTCOffset.Values.Add("utcOffset", utcOffset.ToString());
        UTCOffset.Expires = DateTime.Now.AddDays(1);
        Response.Cookies.Add(UTCOffset);

Instead of cookie value "120", I get value "utcOffset=120" ???

enter image description here

Upvotes: 0

Views: 168

Answers (1)

Caius Jard
Caius Jard

Reputation: 74605

Everything is working as you are telling it to in code. If you want it to be as you say in the question, it would be

    int utcOffset = 120; // added for example sake
    HttpCookie UTCOffset = new HttpCookie("UTCOffset");
    UTCOffset.Value = utcOffset.ToString();
    UTCOffset.Expires = DateTime.Now.AddDays(1);
    Response.Cookies.Add(UTCOffset);

Upvotes: 2

Related Questions