Re: session_set_cookie_params

From: Date: Tue, 29 Jul 2003 22:17:20 +0000
Subject: Re: session_set_cookie_params
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-157460@lists.php.net to get a copy of this message
Hank TT wrote:
I've read the official manual on session handling, as well as the section in "PHP Developer's Cookbook" (2/e, Hughes & Zmievski). But I still cannot make a cookie persist across browser sessions -- very frustrating. I use PHP 4.1.1 running as a CGI in Win32. Here is a snippet: ====================== $lifetime = time() + 8600; session_name('app'); session_start(); .... session_set_cookie_params ($lifetime, '', '.site.com');
    // session_get_cookie_params returns the expected values
.... $_SESSION['userdata'] = $data;
    // Browser, however, says the cookie is due to expire at the end of
session (and it does). ====================== What am I missing here? Thanks.
Call session_set_cookie_params() before you call session_start(). You could also use: ini_set('session.cookie_lifetime',$lifetime); (before session_start() of course) -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ PHP|Architect: A magazine for PHP Professionals – www.phparch.com

« previous php.general (#157460) next »