session_set_cookie_params

This is a discussion on session_set_cookie_params within the PHP General forums, part of the PHP Programming Forums category; Hi, I've read the official manual on session handling, as well as the section in "PHP Developer's ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 07-29-2003
Hank Tt
 
Posts: n/a
Default session_set_cookie_params

Hi,

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.


Also, BTW, I notice the above-mentioned book says session_set_cookie_params
returns o (failure) or 1 (success), but the official documentation says it
returns nothing (void). Is the book in error or is it describing an earlier
version?





Reply With Quote
  #2 (permalink)  
Old 07-29-2003
John W. Holmes
 
Posts: n/a
Default Re: [PHP] session_set_cookie_params

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




Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 07:16 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0