jQuery detecting cookies enabled

You don’t need jQuery for that, you can use vanilla Javascript: function are_cookies_enabled() { var cookieEnabled = (navigator.cookieEnabled) ? true : false; if (typeof navigator.cookieEnabled == “undefined” && !cookieEnabled) { document.cookie=”testcookie”; cookieEnabled = (document.cookie.indexOf(“testcookie”) != -1) ? true : false; } return (cookieEnabled); } http://sveinbjorn.org/cookiecheck

How to manage cookies with UIWebView in Swift

Try this code: SEE COOKIES STORED if let cookies = NSHTTPCookieStorage.sharedHTTPCookieStorage().cookies { for cookie in cookies { NSLog(“\(cookie)”) } } DELETE STORED COOKIES var storage : NSHTTPCookieStorage = NSHTTPCookieStorage.sharedHTTPCookieStorage() for cookie in storage.cookies as! [NSHTTPCookie]{ storage.deleteCookie(cookie) } swift 2.0 let storage = NSHTTPCookieStorage.sharedHTTPCookieStorage() for cookie in storage.cookies! { storage.deleteCookie(cookie) } Swift 3.0 if let cookies … Read more

Is it possible to set more than one cookie with a single Set-Cookie?

The original cookie specification of Netscape (see this cached version) does not say anything about listing multiple cookie declarations. But as of Set-Cookie as defined by RFC 2109 allows a comma separated list of cookie declaration: Informally, the Set-Cookie response header comprises the token Set-Cookie:, followed by a comma-separated list of one or more cookies. … Read more

Setting an httponly cookie with javax.servlet 2.5

You are right, manually setting header is the right way to achive your goal. You can also use javax.ws.rs.core.NewCookie or any other class with useful toString method to print cookie to a header to make things more simple. public static String getHttpOnlyCookieHeader(Cookie cookie) { NewCookie newCookie = new NewCookie(cookie.getName(), cookie.getValue(), cookie.getPath(), cookie.getDomain(), cookie.getVersion(), cookie.getComment(), cookie.getMaxAge(), … Read more

Breaking JavaScript execution when cookie is set

Adding this snippet in the beginning of an html → head block works fine: <script type=”text/javascript”> function debugAccess(obj, prop, debugGet){ var origValue = obj[prop]; Object.defineProperty(obj, prop, { get: function () { if ( debugGet ) debugger; return origValue; }, set: function(val) { debugger; return origValue = val; } }); }; debugAccess(document, ‘cookie’); </script> See this … Read more

Android: How to store cookies?

Use a CookieSyncManager to store your cookie value. It can persist across application starts. Beware of using CookieSyncManager inside of WebViewClient#shouldInterceptRequest on KitKat. It will deadlock. EDIT CookieSyncManager was deprecated in API 21: This class was deprecated in API level 21. The WebView now automatically syncs cookies as necessary. You no longer need to create … Read more

Should cookie values be URL encoded?

Yes. While it’s not required per the spec, the following is mentioned in RFC6265 (emphasis is in the original document, not added) To maximize compatibility with user agents, servers that wish to store arbitrary data in a cookie-value SHOULD encode that data, for example, using Base64 [RFC4648]. In my experience, most web frameworks and libraries … Read more