session_set_cookie_params() must be called before session_start() as
session_start() will send the cookie headers;
To demonstrate that behavior, just run this :

<?php
session_set_cookie_params(3600);
session_start();
var_dump(headers_list());

You should see that the header contains a set-cookie HTTP header, specifying
the cookie lifetime.
Note as well that if the browser doesn't accept the cookie, then PHP will
try to send the session cookie at each request.



2007/12/7, Steven Brown <[EMAIL PROTECTED]>:
>
> After login the details are as follows:
>
> array(5) { ["lifetime"]=> int(604800) ["path"]=> string(1) "/"
> ["domain"]=>
> string(0) "" ["secure"]=> bool(false) ["httponly"]=> bool(false) }
>
> After redirect they are as follows:
>
> array(5) { ["lifetime"]=> int(0) ["path"]=> string(1) "/" ["domain"]=>
> string(0) "" ["secure"]=> bool(false) ["httponly"]=> bool(false) }
>
> Notice I had to turn off the redirect to get the first result.
>
> Note my remember me line is:
>
> Zend_Session::rememberMe(60 * 60 * 24 * 7); // Remember me for 7 days
>
> This is 604800.
>
> Cheers,
> Steven
>
> -----Original Message-----
> From: Laurent Melmoux [mailto:[EMAIL PROTECTED]
> Sent: Friday, 7 December 2007 8:24 PM
> To: Steven Brown
> Cc: 'Darby Felton'; 'Zend Framework General'
> Subject: [fw-general] Re: *** PROBABLY SPAM *** RE: [fw-general]
> Zend_Session::start() and remember me
>
> Do var_dump(session_get_cookie_params()) at the end of your bootstrap
> If you have :
> 'lifetime' => int 1209600 then it is working.
>
> If I call Zend_Session::rememberMe() in my authController I have
> 'lifetime' => int 0 which mean the cookie will die when the browser get
> closed.
>
> Steven Brown a écrit :
> > Yes it definitely works, I login (ticking remember me), close the
> browser,
> > open the browser again and it remembers me.
> >
> > I thought I had to set remember me before starting the session however I
> > found someone else had done the same as I have, and on testing it works.
> >
> > I wonder is the cookie set only when needed, or is the remember me
> cookie
> > set on the next request, which may be caused by my redirect?
> >
> > -----Original Message-----
> > From: Laurent Melmoux [mailto:[EMAIL PROTECTED]
> > Sent: Friday, 7 December 2007 5:35 PM
> > To: Steven Brown
> > Cc: 'Darby Felton'; 'Zend Framework General'
> > Subject: Re: [fw-general] Zend_Session::start() and remember me
> >
> > Are you sure it is working? Zend_Session::rememberMe() is calling
> > Zend_Session::rememberUntil() which is calling the php function
> > session_set_cookie_params () (http://php.net/session_set_cookie_params)
> > . This function configures the cookie use by the session. As Darby said
> > it should be called before session_start() to work.
> >
> > Finally here is how I solve this issue:
> >
> > *In my AuthController, after a successful authentification :*
> >
> > // Set a cookie to notify the bootstrap how long the session cookie
> > should last
> > $duration = $this->_form->rememberme ? 1209600 : 0;
> > setcookie("Zend_Auth_RememberMe", $duration, time()+6000, '/');
> >
> > *In my bootstrap:*
> >
> > // Session
> > include 'Zend/Session.php';
> > if(isset($_COOKIE["Zend_Auth_RememberMe"])){
> > Zend_Session::rememberUntil($_COOKIE["Zend_Auth_RememberMe"]);
> > unset($_COOKIE["Zend_Auth_RememberMe"]);
> > }
> > Zend_Session::start();
> >
> > Regards,
> >
> >
>
>
> --
> Laurent Melmoux - [EMAIL PROTECTED]
> Annecy - France
>
>
>
>

Reply via email to