Firefox session not deleting automatically - javascript

I'm running Linux Mint and using Firefox 3.6.10. I'm setting a cookie using jQuery
$.cookie("ws", "1") ;
This cookie will expires At end of session. But when I close the browser. This session is not expiring automatically. Could you guys help me?

I had similar problem. It happens when you set up your browser to remember opened tabs. In this case firefox does not delete session cookies, since the session didn't ended, and will continue when browser is opened again

Related

how do I isolate session (cookie and localstorage) in tab for chrome extension

I tried to make chrome extension to isolate session, cookies and localstorage for each tab in chrome just like sessionbox. but How do they manage it to separate session each tab?
I've tried to call little api to store cookies each tab and put it back in chrome but it seems not like how sessionbox isolate their session. Do you have any idea how session in sessionbox works?

Javascript - cookie cleared after browser is closed?

I'm trying to set cookie that would last after browser is closed. Though every-time I close browser, cookie disappears. I thought cookies supposed to be kept even if browser is closed? Unless specified to be deleted after some time?
For example:
console.log("cookies ", document.cookie)
document.cookie = "some_cookie=true; max-age=31536000";
First time opening page with this JS code, it prints cookies.
After refreshing browser, it prints cookies some_cookie=true
After closing browser and opening same page again, it prints cookies.
I tested on Firefox 65.0.2 (64-bit), Chrome 72.0.3626.109 (Official Build) (64-bit) and Chromium 71.0.3578.98 (Official Build) Built on Ubuntu , running on Ubuntu 16.04 (64-bit) (for Chrome and Chromium had to use http server, because it would not allow to set cookies at all, if raw html file was opened directly).
Results are all the same, after I close browser, my cookie is deleted. I also checked if there was an option to clear cookies on closing browser, but it is not enabled.
Am I doing something wrong here? Or cookies are outdated and I should just stick to localStorage?
P.S. I tried using max-age, expires or not using those at all, but result is the same.
For me what worked, was to specify max-age when storing cookie. But also when testing I had to use web server to serve my html file, because opening plain html file directly on browser, does not make it to be stored up to specified duration. Even if it says it will expire on some date, it still deletes cookie when browser is closed (this is kind of inconsistent).
So default behavior is it expires when session is closed, and to change that, need to specify some duration via expires or max-age attributes.
As per Mozzila documentation: "If neither expires nor max-age specified it will expire at the end of session."
https://developer.mozilla.org/en-US/docs/Web/API/Document/cookie#Write_a_new_cookie

Why Google Chrome does not delete session cookie when restart after crash?

My web page set a session cookie when the user is connected.
If i kill the chrome process on windows, and then i restart the browser, my session cookie is here ! Why ?
Is there a way to prevent this behaviour ?
This is a feature, not a bug. Crashes usually are not intentional, and it would be a huge inconvenience to the user to have to log into everything all over again.
Crashing is not the same as exiting. If you want to restart the browser, quit it the normal way, not by killing it.

In iOS Safari, cookie data gets destroyed on closing browser from background. I don't want to lose cookie data on closing the browser?

I'm using jQuery Mobil & .Net to develop a mobile website. I'm storing authentication token in cookie when user checks "keep me logged in", so next time there is no need to log-in. But when I close the browser from background in iPhone cookie file exist but there is no data in it.
I had the same problem. Switching "Private navigation" off on the iphone did help.

Chrome doesn't delete session cookies

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.
This can be caused by having Chrome set to Continue where you left off.
Further reading
Bug report: Chrome is not deleting temporary cookies – i.e. not logging me out automatically when I close all browser Windows
Issue 128513 in Chromium: Session Cookies not cleared when Chrome processes closed
Issue 128567: Session only cookies don't delete
I 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.
I 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.
I had to both, unchecked, under advanced settings of Chrome :
'Continue running background apps when Google Chrome is closed'
"Continue where I left off", "On startup"
This maybe because Chrome is still running in background after you close the browser. Try to disable this feature by doing following:
Open chrome://settings/
Click "Show advanced settings ..."
Navigate down to System section and disable "Continue running background apps when Google Chrome is closed".
This will force Chrome to close completely and then it will delete session cookies.
However, I think Chrome should check and delete previous session cookies at it starting instead of closing.
A 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.
This 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).
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".
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.
Go to chrome://settings/content/cookies?search=cookies
Enable Clear cookies and site data when you quit Chrome.
Worked for me
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.
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.
The solution would be to use sessionStorage, FYI: https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage
Google 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);

Categories