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

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.

| improve this answer | |
  • 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? – E. de Saint Chamas Oct 17 '11 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!!! – Yuseferi Sep 4 '12 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

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.