Android HttpClient and Cookies

I had the same problem and I used similar approach as in the question with no luck. The thing that made it work for me was to add the domain for each copied cookie. (BasicClientCookie cookie.setDomain(String)) My util function: public static BasicCookieStore getCookieStore(String cookies, String domain) { String[] cookieValues = cookies.split(“;”); BasicCookieStore cs = new … Read more

How is HttpOnly get set for ASP.NET_SessionId cookie?

ASP.NET session cookies are HTTP only, regardless of the httpOnlyCookies setting linked to in your question, because this is burned into ASP.NET. You can’t override this. If you dig into the System.Web.SessionState.SessionIDManager class in the System.Web assembly the code for creating the ASP.NET session cookie looks like: private static HttpCookie CreateSessionCookie(string id) { HttpCookie cookie … Read more

Setting a cookie in an AJAX request?

Here are few suggestions: Make sure that you are specifying the correct expiration format of date When setting a cookie on a page that redirects, the cookie must be set after the call to header(‘Location: ….’); eg: header(‘Location: http://www.example.com/’); setcookie(‘asite’, $site, time()+60*60, “https://stackoverflow.com/”, ‘site.com’); If you have human urls like www.domain.com/path1/path2/, then you must set … Read more

How to modify Cookie from Ajax call

The Cookie header is one of several which cannot be modified in an XMLHttpRequest. From the specification: Terminate [execution of the setRequestHeader method] if header is a case-insensitive match for one of the following headers: Accept-Charset Accept-Encoding Connection Content-Length Cookie Cookie2 Content-Transfer-Encoding Date Expect Host Keep-Alive Referer TE Trailer Transfer-Encoding Upgrade User-Agent Via … or … Read more

Cookies not working on different pages

Which directory are you in when the cookie gets set? From the PHP manual on setcookie(), emphasis mine: Path The path on the server in which the cookie will be available on. If set to “https://stackoverflow.com/”, the cookie will be available within the entire domain . If set to ‘/foo/’, the cookie will only be … Read more

ASP.NET Session Cookies – specifying the base domain

Create a ISessionIDManager, since you only want to change the cookie domain we will let the default one do all the work. This is configured in web.config on the sessionState element under <system.web>. <sessionState sessionIDManagerType=”MySessionIDManager” /> And the implementation. public class MySessionIDManager: SessionIDManager, ISessionIDManager { void ISessionIDManager.SaveSessionID( HttpContext context, string id, out bool redirected, out … Read more

Getting setting cookies on different domains, with JavaScript or other

You could inject a script element into HEAD of the document with a callback that passes the cookie you need to whatever function needs it. Something like: <script type=”text/javascript”> var newfile=document.createElement(‘script’); newfile.setAttribute(“type”,”text/javascript”); newfile.setAttribute(“src”, ‘http://first.com/doAjax?getCookie&callback=passCookie’); document.getElementsByTagName(“head”)[0].appendChild(newfile); </script> And the page first.com/doAjax?getCookie could do this: passCookie({‘name’:’mycookie’, ‘value’:’myvalue’});