Reputation: 1167
Using JavaScript, is it possible to inject an iframe and have the iframe hold no cookie/session data? Effectively an 'incognito' iframe?
The reason for this is a Chrome extension I was thinking about, where I'd like to display a preview of pre-auth pages of other websites, and so to ensure they're not redirected the iframe would ideally non use existing cookie data.
I know this is similar to this question, but I don't have full control of the pages I'm previewing in the iframe.
Upvotes: 3
Views: 2856
Reputation: 92461
If you don't use any HTTP-only cookies, you could save a copy of all cookies in localStorage
, remove all cookies, load the iframe, and restore the cookies from localStorage
.
Pseudo-code:
localStorage.setItem("cookies", document.cookie);
removeAllCookies();
openIframe();
document.cookie = localStorage.cookies;
localStorage.removeItem("cookies");
Another way is to create a proxy on your server, which wouldn't use cookies. For example request to http://example.com/proxy?url=/preview
would make a request to http://example.com/preview
without cookies.
Upvotes: 2