I experienced problems with PHP non-persistent cookies, so I feel safer
writing them explicitly on the client's disk:

all the protected pages in one of my applications start by:

// session check
session_start() ;
setcookie( session_name(), session_id(), time()+3600, "/" ) ;
ob_start() ;
require "../../cgi-bin/common.php" ;

// check if access is authorized
if ( !isset( $_SESSION['USERID'] ) )
{
etc

HTH
Ignatius
____________________________________________
----- Original Message -----
From: "Stephen Edmonds" <[EMAIL PROTECTED]>
To: "PHP Helplist Windows" <[EMAIL PROTECTED]>
Sent: Monday, October 14, 2002 10:38 PM
Subject: [PHP-WIN] Php Sessions - Well, they don't work :-\


> The problem is my sessions don't work properly... the ID is stored and
saved
> in the cookie fine, and the PHP script can even acces the Session ID value
> in the cookie. However, when you call session_start(); it mearly creates a
> new session/session ID instead of resuming.
> I can pass on the session id using
> $target = "http://url.com?".CID;
> header( "Location: $target" );
> but obviously doing that is not what I want to do for every page/link. I
> wrote a script to test the session function. The sessions are set in a
> script using session_register() and the variables are stored perfectly
fine
> in the session folder, even the session ID's match with the output of CID.
>
> The Code:
> print "Session ID = ".session_id()."<br>";
> print "Searching for cookie ID ( $_ENV[COOKIE] ) <br>";
>
> Firstly, I called the code before session_start(); just to see what
happens.
> It returns:
>
> Session ID =
> Searching for cookie ID ( PHPSESSID=7c7b9b50c724fc18c59c436d78b4992d )
>
> Remember, thats before I call session_start();
> However, Exactly the same code used after session_start(); returns
something
> different...
>
> Session ID = e6c9f37a45808b552b8f04ee06968d42
> Searching for cookie ID ( PHPSESSID=7c7b9b50c724fc18c59c436d78b4992d )
>
> So, as you can see, Session_Start(); has actually started a NEW session
> rather than the old session refered to in the session cookie. This is most
> annoying... and I have no idea what could be causing it.
>
> Thank you for your time. I hope I have explained it fairly well...
>
> Stephen
>
> [Web Server Details]
> Platform - Windows XP (Admin Account)
> Server - Xitami
>
> [PHP.INI File]
>
> register_globals = On
>
>  [Session]
> session.save_handler = files
> session.save_path = C:\server\PHP\sessiondata    ; argument passed to
> save_handler
> session.use_cookies = 1
> session.name = PHPSESSID
> session.auto_start = 0
> session.cookie_lifetime = 1800
> session.cookie_path = /
> session.cookie_domain =
> session.serialize_handler = php
> session.gc_probability = 1
> session.gc_maxlifetime = 1800
> session.referer_check =
> session.entropy_length = 0
> session.entropy_file =
> ;session.entropy_length = 16 (Yes, they are commented out ; in php.ini)
> ;session.entropy_file = /dev/urandom (Yes, they are commented out ; in
> php.ini)
> session.cache_limiter = nocache
> session.cache_expire = 180
> session.use_trans_sid = 0
> url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=fakeentry
>
>
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to