Questions tagged [httpcookiecollection]

9 questions
24
votes
1 answer

HttpCookieCollection.Add vs HttpCookieCollection.Set - Does the Request.Cookies collection get copied to the Response.Cookies collection?

I just want to clear this up. I know that if I have set a cookie on a previous request, it will show up in my Request.Cookies collection. I want to update my existing Cookie. Are the cookies from my Request.Cookies collection already copied to…
smartcaveman
  • 38,142
  • 26
  • 119
  • 203
8
votes
1 answer

Deserialize a json serialized CookieCollection

In my code I have to Json serialize a CookieCollection object and pass it as string, to achieve this I do like this: var json = Newtonsoft.Json.JsonConvert.SerializeObject(resp.Cookies); resulting to the following json [ { "Comment": "", …
8
votes
1 answer

Why does HttpCookieCollection.Get returns null when called from a manually instantiated object (and not from the current HttpContext)

In the HttpCookieCollection.Get MSDN documentation, it is stated that: If the named cookie does not exist, this method creates a new cookie with that name. This is true and works well when calling HttpContext.Request.Cookies or…
Vincent de Lagabbe
  • 4,354
  • 3
  • 28
  • 35
1
vote
1 answer

What is the best practice for updating a cookie that was set on a previous request in ASP.NET?

Here is the scenario. A cookie with the key "MyCookie" has been set on a previous request. I can access it via HttpContext.Request.Cookies.Get("MyCookie"). I want to perform an update such as adding another value to the Cookie Values collection,…
smartcaveman
  • 38,142
  • 26
  • 119
  • 203
0
votes
0 answers

Cookie sent in rediret response are getting ifnored

In login implementation, backend API is redirecting user home page along with setting the session cookie. But when Browser invokes redirect request to home page, this cookie is not getting set- Request URL:…
0
votes
1 answer

How can I update a request CookieCollection after after removing/deleting a cookie object from the collection in CakePHP

I am having problems working with request cookies on my project. I have a cookie collection with about 3 values a, b, and c. Then I try the following for instance: $cookieCollection = $this->getRequest()->getCookieCollection(); if…
I_am_NHO
  • 27
  • 8
0
votes
1 answer

C# HttpWebRequest Use cookie

I have a little problem with cookie handling in C# So on my web site, I have a login page, once logged in, I am redirected to the home page. I get with HttpWebRequest to connect and follow the redirection, I created a class, here it is : class…
Y.op
  • 69
  • 1
  • 9
0
votes
0 answers

I only seem to be able to set one Cookie - HttpCookie, asp.net

I have a system with a two-stage login. Stage one is a Company Login which identifies the Company using my system. Stage two is a Staff Login where a member of staff belonging to the above company logs in. In both stage an option is offered to save…
Jamie Hartnoll
  • 6,673
  • 12
  • 53
  • 89
0
votes
1 answer

Sharepoint 2010 setting a cookie expiration date seemsto work when viewed from browser but server code sees 01/01/0001 expiration

here is the to add the cookie to the request HttpCookie cookie = new HttpCookie(myCookie); cookie.Expires = DateTime.Now.AddDays(30); cookie.Value = myValue; cookie.Domain = myDomain; cookie.HttpOnly = true; …
Anthony
  • 527
  • 1
  • 8
  • 26