[PHP] Re: Sessions still do not persist

2004-05-21 Thread Torsten Roehr
Michael R. Wayne [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]

 I've posted several times mentioning that I am completely unable
 to cause sessions to persist.  Over the intervening time, I have
 replicated this problem to a different machine, with the same
 results.  Here's a recap of the problem.

 I am not using cookies.  Sessions are automatically created (and
 changing that makes no difference)  The relevant session variables
 (copied from phpinfo) are:
Session Support  enabled
session.auto_start   On - hence no session_start
session.name PHPSESSID
session.use_cookies  Off - no cookies
session.use_trans_sidOn

 Environment is FreeBSD4.8.  phpinfo for apache says:
Apache/1.3.29 (Unix) mod_perl/1.28 PHP/4.3.4 mod_ssl/2.8.16
OpenSSL/0.9.6d


 Here is a cut/paste of the borwser screen for the code below:

Stage:0 SessionID: 04ace04b1fe0bc81d2cd678c9bab1619
_ [Submit]
Stage:1 SessionID: 04ace04b1fe0bc81d2cd678c9bab1619 Request: Array ( )

 So I type foo into the box and hit submit.  And the session variable
 is NOT preserved:

Stage:0 SessionID: 55c70989b7279d6a18edfd81b28d67a6
foo___ [Submit]
Stage:1 SessionID: 55c70989b7279d6a18edfd81b28d67a6 Request: Array
 [PHPSESSID] = 04ace04b1fe0bc81d2cd678c9bab1619 [field] = foo )

 The session directory IS writable and I see the expected information
 being written there:
-rw---  1 nobody   wheel  10 May 21 13:35
sess_04ace04b1fe0bc81d2cd678c9bab1619
-rw---  1 nobody   wheel  10 May 21 13:38
sess_55c70989b7279d6a18edfd81b28d67a6

 Apache runs as user nobody on this server.  Both session files contain:
stage|i:1;
 but the files never seem to be being read back!

 Help!?


 Here's the entire php code I'm testing with:

 ?
 if (!isset($_SESSION['stage'])) {
$_SESSION['stage'] = 0;
}
 if (!isset($_POST['field'])) { $_POST['field'] = ; }
 ?
 html
 headtitlePHP Test page/title/head
 body
 ?
   echo Stage:; echo $_SESSION['stage'];
   echo  SessionID: ; echo session_id();
   $_SESSION['stage'] = 1;
 ?
form method=post action=xxx.php
   input type=text maxlength=7 size=7 name=field value=?echo
$_POST['field']?
   input type=submit value=Submit
/form
 ?
   echo Stage:; echo $_SESSION['stage']; echo  ;
   echo  SessionID: ; echo session_id(); echo  ;
   echo  Request: ; print_r($_REQUEST);
 ?
 /body /html

As far as I remember session.use_trans_sid does NOT work with forms (action
attribute). Have you tried appending it manually to the action?:

form method=post action=xxx.php?= SID; ?

Regards, Torsten

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



Re: [PHP] Re: Sessions still do not persist

2004-05-21 Thread Michael R. Wayne
On Fri, May 21, 2004 at 08:04:00PM +0200, Torsten Roehr wrote:
 
 As far as I remember session.use_trans_sid does NOT work with forms (action
 attribute). Have you tried appending it manually to the action?:

Well, this certainly seems to be progress in the correct direction.
So session.use_trans_sid used to work with forms in 4.1.2 (I'm
suffering from an upgrade here) but no longer does?  This really
helps.

 form method=post action=xxx.php?= SID; ?

This ALMOST works.  Looks like a seperator is needed.  I get:
   POST /xxx.phpPHPSESSID=3a2c0413ec84a00e36ea0317c193ccb2 HTTP/1.1

Do I want ?=PHPSESSID=sessionID or just ?=sessionID or what?

Thanx!

/\/\ \/\/

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



Re: [PHP] Re: Sessions still do not persist

2004-05-21 Thread Torsten Roehr

Michael R. Wayne [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 On Fri, May 21, 2004 at 08:04:00PM +0200, Torsten Roehr wrote:
 
  As far as I remember session.use_trans_sid does NOT work with forms
(action
  attribute). Have you tried appending it manually to the action?:

 Well, this certainly seems to be progress in the correct direction.
 So session.use_trans_sid used to work with forms in 4.1.2 (I'm
 suffering from an upgrade here) but no longer does?  This really
 helps.

  form method=post action=xxx.php?= SID; ?

 This ALMOST works.  Looks like a seperator is needed.  I get:
POST /xxx.phpPHPSESSID=3a2c0413ec84a00e36ea0317c193ccb2 HTTP/1.1

 Do I want ?=PHPSESSID=sessionID or just ?=sessionID or what?

Sorry, I'm an idiot! The ? was missing:

form method=post action=xxx.php??= SID; ?

This should work. As far as I have seen trans_sid is not used very often -
obviously because of problems like yours. The best way is always to pass the
session ID yourself. Either with a cookie or via GET. I prefer GET because
with cookies you are reliant on the client supporting/allowing cookies.

Regards, Torsten

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



Re: [PHP] Re: Sessions still do not persist

2004-05-21 Thread Michael R. Wayne
On Fri, May 21, 2004 at 08:35:37PM +0200, Torsten Roehr wrote:
 
 Sorry, I'm an idiot! The ? was missing:
 
 form method=post action=xxx.php??= SID; ?

Thank you, thank you.  This does indeed seem to work in my test script.
Now to go work on the real version.

 This should work. As far as I have seen trans_sid is not used very often -
 obviously because of problems like yours. The best way is always to pass the
 session ID yourself. Either with a cookie or via GET. I prefer GET because
 with cookies you are reliant on the client supporting/allowing cookies.

Oddly, this all worked properly under 4.1.2.  When we upgraded,
things broke.  And I have a strong personal bias against cookies.

One again, thank you for the solution!

/\/\ \/\/

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



Re: [PHP] Re: Sessions still do not persist

2004-05-21 Thread Michael R. Wayne
On Fri, May 21, 2004 at 08:35:37PM +0200, Torsten Roehr wrote:
 Sorry, I'm an idiot! The ? was missing:
 
 form method=post action=xxx.php??= SID; ?
 

Well, I spoke too soon.  It does work, but only the SECOND time the 
script is run!

   Stage:0 SessionID: 6c9a1819fe95fa6f08f385ee2afa71ca 
   __ [Submit]
   Stage:1 SessionID: 6c9a1819fe95fa6f08f385ee2afa71ca Request: Array ( ) 
Type foo into the form, hit submit and the session variable is not being
preserved:
   Stage:0 SessionID: ac429ad0086eb5b4d1130eb2e2fddcb9 
   foo___ [Submit]
   Stage:1 SessionID: ac429ad0086eb5b4d1130eb2e2fddcb9 Request: Array ( [PHPSESSID] = 
6c9a1819fe95fa6f08f385ee2afa71ca [field] = foo ) 
Type bar into the form, hit submit and the session variable
IS being preserved:
   Stage:1 SessionID: ac429ad0086eb5b4d1130eb2e2fddcb9 
   bar___ [Submit]
   Stage:1 SessionID: ac429ad0086eb5b4d1130eb2e2fddcb9 Request: Array ( [PHPSESSID] = 
ac429ad0086eb5b4d1130eb2e2fddcb9 [field] = bar ) 

So, what am I missing here?


Code, for reference:
?
if (!isset($_SESSION['stage'])) {
   $_SESSION['stage'] = 0;
   }
if (!isset($_POST['field'])) { $_POST['field'] = ; }
?
html
headtitlePHP Test page/title/head
body
?
  echo Stage:; echo $_SESSION['stage'];
  echo  SessionID: ; echo session_id();
  $_SESSION['stage'] = 1;
?
   form method=post action=xxx.php??= SID; ?
  input type=text maxlength=7 size=7 name=field value=?echo 
$_POST['field']?
  input type=submit value=Submit
   /form
?
  echo Stage:; echo $_SESSION['stage']; echo  ;
  echo  SessionID: ; echo session_id(); echo  ;
  echo  Request: ; print_r($_REQUEST);
?
/body /html

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



Re: [PHP] Re: Sessions still do not persist

2004-05-21 Thread Torsten Roehr
Michael R. Wayne [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 On Fri, May 21, 2004 at 08:35:37PM +0200, Torsten Roehr wrote:
  Sorry, I'm an idiot! The ? was missing:
 
  form method=post action=xxx.php??= SID; ?
 

 Well, I spoke too soon.  It does work, but only the SECOND time the
 script is run!

Stage:0 SessionID: 6c9a1819fe95fa6f08f385ee2afa71ca
__ [Submit]
Stage:1 SessionID: 6c9a1819fe95fa6f08f385ee2afa71ca Request: Array ( )
 Type foo into the form, hit submit and the session variable is not being
 preserved:
Stage:0 SessionID: ac429ad0086eb5b4d1130eb2e2fddcb9
foo___ [Submit]
Stage:1 SessionID: ac429ad0086eb5b4d1130eb2e2fddcb9 Request: Array
 [PHPSESSID] = 6c9a1819fe95fa6f08f385ee2afa71ca [field] = foo )
 Type bar into the form, hit submit and the session variable
 IS being preserved:
Stage:1 SessionID: ac429ad0086eb5b4d1130eb2e2fddcb9
bar___ [Submit]
Stage:1 SessionID: ac429ad0086eb5b4d1130eb2e2fddcb9 Request: Array
 [PHPSESSID] = ac429ad0086eb5b4d1130eb2e2fddcb9 [field] = bar )

 So, what am I missing here?

You could try it without session.auto_start. Turn it off and put
session_start() at the top of the script (in all pages).

Regards, Torsten

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



Re: [PHP] Re: Sessions still do not persist

2004-05-21 Thread Michael R. Wayne
On Fri, May 21, 2004 at 09:12:02PM +0200, Torsten Roehr wrote:
 
  So, what am I missing here?
 
 You could try it without session.auto_start. Turn it off and put
 session_start() at the top of the script (in all pages).

Tried that - makes no difference.  Still works properly on the second
call but not the first.

/\/\ \/\/

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