3

How to modify Drupal user's cookie so the cookie is not available anymore after a predefined time or when the user close his web browser or close all of the websites pages open in tabs ?

After some online searches i found that by setting the cookie lifetime to 0 should create temporary cookies that would be deleted once the browser is closed:

I first tried by modifing some ini_set() values in the settings.php :

ini_set('session.cookie_lifetime', 0); ini_set('session.gc_maxlifetime', 0); 

I created a php.ini file located at the drupal site root, containing:

session.cookie_lifetime = 0; 

But it does not work on my test site. Any ideas?

2 Answers 2

2

You can change this setting directly in the settings.php. You've a line that looks like that :

ini_set('session.cookie_lifetime', 2000000);

Change 2000000 to 0 and you will get what you want.

2
  • Thanks for the reply. I already tried but it doesn't seems to work (on Chrome) i'll check with different browsers. -- EDIT -- It does work on Firefox but not on Chrome apparently. Any idea why? Commented Oct 17, 2011 at 6:22
  • 2
    It's not work with closing tab,Firefox kill lifetime of session_cookie only with close firefox compeletly , if you close only drupal opened tabs this method not work!!! Commented Sep 4, 2012 at 5:20
2

Since Chrome 22 any extensions or apps that run in the background prevent Chrome from purging session cookies. This is by design, but they admit it's a potential issue and will consider a redesign. https://code.google.com/p/chromium/issues/detail?id=142555

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.