Persistent session cookies: remember session even after closing the browser I would like to store anonymous users $_SESSION in a cookie so that their cart and other custom information is still available even after closing the browser.

I found this interesting post which tells me I should add this to my local.settings.php:

ini_set('session.cookie_lifetime', 60 * 60 * 24 * 7);
ini_set('session.gc_maxlifetime', 60 * 60 * 24 * 7);
ini_set('session.save_path', '/home/yoursite/sessions');


So that session cookie would be available for a week.
But it also stands that we should use session_regenerate_id() elseway the cookie lifetime is not updated.

I could not find session_regenerate_idin Drupal 7 source code, but I believe Drupal might already handle this from what I read in the code comments.

My questions are:


is this a good approach to have persistent cookie sessions?
do I need to add to my local.settings.php session_regenerate_id() too?


Thank you very much for your advises
Hi you could use javascript for this. 

Using these 3 functions. 
its properly the best way and then you wont have problems if your are using Varnish

function createCookie(name,value,days) {
    if (days) {
        var date = new Date();
        date.setTime(date.getTime()+(days*24*60*60*1000));
        var expires = "; expires="+date.toGMTString();
    }
    else var expires = "";
    document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for(var i=0;i &lt; ca.length;i++) {
        var c = ca[i];
        while (c.charAt(0)==' ') c = c.substring(1,c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
    }
    return null;
}

function eraseCookie(name) {
    createCookie(name,"",-1);
}