Asked 13 years, 3 months ago
Viewed 219k times
I'm trying to set session cookie in javascript like this:
document.cookie = 'name=alex; path=/'
But Chrome doesn't delete it even if I quit browser and launch it again.
I checked in Firefox and Opera and both work as intended - they delete session cookie on browser exit.
Is Chrome just ignoring expiration rules?
I checked in multiple OSes and found out that session cookie gets removed on Chrome in Windows XP and Ubuntu, but NOT in Mac OSX Lion.
asked May 16, 2012 at 11:54
mgsmgs2,67922 gold badges1919 silver badges1515 bronze badges
3 Andrew Morton25.2k99 gold badges6666 silver badges9595 bronze badges
answered May 27, 2012 at 7:42
JesperJesper2,79411 gold badge1616 silver badges22 bronze badges
11I just had the same problem with a cookie which was set to expire on "Browsing session end".
Unfortunately it did not so I played a bit with the settings of the browser.
Turned out that the feature that remembers the opened tabs when the browser is closed was the root of the problem. (The feature is named "On startup" - "Continue where I left off". At least on the current version of Chrome).
This also happens with Opera and Firefox.
answered Feb 8, 2013 at 13:03
Nikola KolevNikola Kolev1,27933 gold badges1717 silver badges2525 bronze badges
5I just had this issue. I noticed that even after I closed my browser I had many Chrome processes running. Turns out these were each from my Chrome extension.
Under advanced settings I unchecked 'Continue running background apps when Google Chrome is closed'
and my session cookies started working as they should.
Still a pain in the rear for all of us developers that have been coding expecting that session cookies would get cleared when the user is done browsing.
kahlan8810111 silver badge88 bronze badges
answered Sep 25, 2012 at 22:26
NSjonasNSjonas12.3k1111 gold badges7676 silver badges103103 bronze badges
3I had to uncheck both of these, under advanced settings of Chrome:
2,50211 gold badge2424 silver badges3939 bronze badges
answered Feb 11, 2015 at 1:49
emottetemottet46566 silver badges1818 bronze badges
2This maybe because Chrome is still running in background after you close the browser. Try to disable this feature by doing following:
However, I think Chrome should check and delete previous session cookies at it starting instead of closing.
answered Oct 24, 2013 at 8:16
JustmyhobbyJustmyhobby11911 silver badge22 bronze badges
0A simple alternative is to use the new sessionStorage object. Per the comments, if you have 'continue where I left off' checked, sessionStorage will persist between restarts.
answered Nov 21, 2013 at 21:56
TimDogTimDog8,94855 gold badges4444 silver badges5252 bronze badges
3This issue is caused because you are using Continue where I left off
and Continue running background apps when Google Chrome is closed
feature of chrome (currently my version is 96).
Please consider setting those off (to test functionality).
answered Dec 21, 2021 at 10:50
Ismoil ShokirovIsmoil Shokirov3,12944 gold badges2424 silver badges4040 bronze badges
I had the same problem with "document.cookie" in Windows 8.1, the only way that Chrome deletes the cookie was shutting it from task manager (not a really fancy way), so I decided to manage the cookies from the backend or use something like "js-cookie".
answered Jun 5, 2015 at 21:04
TurKuxTurKux10511 silver badge33 bronze badges
Have you tried to Remove hangouts extension in Google Chrome? because it forces chrome to keep running even you close all the windows.
I was also facing the problem but it resolved now.
answered Aug 14, 2013 at 5:49
If you set the domain for the php session cookie, browsers seem to hold on to it for 30 seconds or so. It doesn't seem to matter if you close the tab or browser window.
So if you are managing sessions using something like the following it may be causing the cookie to hang in the browser for longer than expected.
ini_set("session.cookie_domain", 'www.domain.com');
The only way I've found to get rid of the hanging cookie is to remove the line of code that sets the session cookie's domain. Also watch out for session_set_cookie_params() function. Dot prefixing the domain seems to have no bearing on the issue either.
This might be a php bug as php sends a session cookie (i.e. PHPSESSID=b855ed53d007a42a1d0d798d958e42c9
) in the header after the session has been destroyed. Or it might be a server propagation issue but I don't thinks so since my test were on a private servers.
answered Jan 17, 2018 at 3:00
SurferJoeSurferJoe99511 gold badge88 silver badges1313 bronze badges
I just had this problem of Chrome storing a Session ID but I do not like the idea of disabling the option to continue where I left off. I looked at the cookies for the website and found a Session ID cookie for the login page. Deleting that did not correct my problem. I search for the domain and found there was another Session ID cookie on the domain. Deleting both Session ID cookies manually fixed the problem and I did not close and reopen the browser which could have restored the cookies.
answered Mar 7, 2019 at 20:31
Go to chrome://settings/content/cookies?search=cookies
Enable Clear cookies and site data when you quit Chrome
.
Worked for me
answered Mar 25, 2020 at 18:41
Mihai PerjuMihai Perju2522 silver badges1313 bronze badges
1Google chrome has a problem if you set and unset cookie improper way. This is php code. Thought this will give you idea.
Set cookie
setcookie('userLoggedIn', 1, 0, PATH);
Wrong way and will not work (notice PATH is missing)
setcookie('userLoggedIn', 0, time()-3600);
Correct way fixes issue on google chrome
setcookie('userLoggedIn', 0, time()-3600, PATH);
answered Nov 28, 2014 at 16:18
1Start asking to get answers
Find the answer to your question by asking.
Ask questionExplore related questions
See similar questions with these tags.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4