[PHP] sessions failing to persist

2004-05-02 Thread Michael R. Wayne

As I posted last week, I seem unable to have sessions persist.  I
have ruled out https as a problem, the following simple script,
installed as xxx.php will generate a new session number every time
the field is filled in and Submit is hit.

Note that I am not using cookies, the relevant session variables are:
   Session Support  enabled
   session.auto_start   On
   session.use_cookies  Off
   session.use_trans_sidOn

When run, the session file appears to contain stage=1 but never is being
read.

I suspect I'm missing something obvious, any pointers?

/\/\ \/\/

?
if (!session_is_registered(stage)) {
   $_SESSION[stage] = 0;
   $_POST['field'] = ;
   session_register(stage);
   }
?
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];
?

/body /html

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



Re: [PHP] sessions failing to persist

2004-05-02 Thread John Nichel
Michael R. Wayne wrote:

As I posted last week, I seem unable to have sessions persist.  I
have ruled out https as a problem, the following simple script,
installed as xxx.php will generate a new session number every time
the field is filled in and Submit is hit.
Note that I am not using cookies, the relevant session variables are:
   Session Support  enabled
   session.auto_start   On
   session.use_cookies  Off
   session.use_trans_sidOn
When run, the session file appears to contain stage=1 but never is being
read.
I suspect I'm missing something obvious, any pointers?
I copy and pasted your code, and didn't get the results you described 
above.  Basically, it all worked fine on my box (and now I have to go 
put my ini settings back to my normal values ;)

Is this a *nix or Windows machine?  Is your session directory writable 
by the webserver user?

--
By-Tor.com
It's all about the Rush
http://www.by-tor.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] sessions failing to persist

2004-05-02 Thread Michael R. Wayne
On Mon, May 03, 2004 at 12:54:54AM -0400, John Nichel wrote:
 Michael R. Wayne wrote:
 
 As I posted last week, I seem unable to have sessions persist.  I
 have ruled out https as a problem, the following simple script,
 installed as xxx.php will generate a new session number every time
 the field is filled in and Submit is hit.
 
 Note that I am not using cookies, the relevant session variables are:
Session Support  enabled
session.auto_start   On
session.use_cookies  Off
session.use_trans_sidOn
 
 When run, the session file appears to contain stage=1 but never is being
 read.
 
 I suspect I'm missing something obvious, any pointers?
 
 I copy and pasted your code, and didn't get the results you described 
 above.  Basically, it all worked fine on my box (and now I have to go 
 put my ini settings back to my normal values ;)
 
 Is this a *nix or Windows machine?  Is your session directory writable 
 by the webserver user?

FreeBSD 4.8 Unix.  Yes, the session directory is writable and the
files are getting properly written to that directory - the problem
is that they are never being read (so each time I click Submit, I
get a new session ID).

/\/\ \/\/

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



Re: [PHP] sessions failing to persist

2004-05-02 Thread Richard Harb
If the sample of code is the whole page... where do you actually start
your session?

I didn't see a session_start() anywhere.

AFAIK the $_SESSION var doesn't exist until you do just that.

session_is_registered(): mabe I'm reading the documentation wrong, but
I interpret this function as checking whether there is the global var
(in this case $stage) ... and since register_globals is off there
shouldn't be such a var automatically any more.

..

In the user comments there's a good example of how to handle sessions.

http://www.php.net/session_is_registered#26464

hth
Richard


Monday, May 3, 2004, 6:40:18 AM, thus was written:

 As I posted last week, I seem unable to have sessions persist.  I
 have ruled out https as a problem, the following simple script,
 installed as xxx.php will generate a new session number every time
 the field is filled in and Submit is hit.

 Note that I am not using cookies, the relevant session variables are:
Session Support  enabled
session.auto_start   On
session.use_cookies  Off
session.use_trans_sidOn

 When run, the session file appears to contain stage=1 but never is being
 read.

 I suspect I'm missing something obvious, any pointers?

 /\/\ \/\/

 ?
 if (!session_is_registered(stage)) {
$_SESSION[stage] = 0;
$_POST['field'] = ;
session_register(stage);
}
?
 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];
?

 /body /html

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



Re: [PHP] sessions failing to persist

2004-05-02 Thread Michael R. Wayne
On Mon, May 03, 2004 at 06:55:25AM +0200, Richard Harb wrote:
 If the sample of code is the whole page... where do you actually start
 your session?

I am using session.auto_start, which starts it for me.  I added a
session_start while testing and it made no difference.

 session_is_registered(): mabe I'm reading the documentation wrong, but
 I interpret this function as checking whether there is the global var
 (in this case $stage) ... and since register_globals is off there
 shouldn't be such a var automatically any more.

 In the user comments there's a good example of how to handle sessions.
 
 http://www.php.net/session_is_registered#26464

OK, replaced it with the following, no change in behaviour.  I still get 
a new sessionID every time I hit Submit.

?
if (!isset($_SESSION[stage])) {
   $_SESSION[stage] = 0;
   $_POST['field'] = ;
   session_register(stage);
   }
?
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];
?
/body /html

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



Re: [PHP] sessions failing to persist

2004-05-02 Thread John W. Holmes
Michael R. Wayne wrote:
   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
Try adding in a hidden element

input type=hidden name=PHPSESSID value=?=session_id();?

You're relying on PHP rewriting your forms, links, etc, to include the 
session id, but that doesn't seem to be happening.

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals  www.phparch.com

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


Re: [PHP] sessions failing to persist

2004-05-02 Thread Curt Zirzow
* Thus wrote Michael R. Wayne ([EMAIL PROTECTED]):
 
 I suspect I'm missing something obvious, any pointers?
 
 /\/\ \/\/
 
 ?
 if (!session_is_registered(stage)) {
$_SESSION[stage] = 0;
$_POST['field'] = ;
session_register(stage);
}

manual
Caution 

If you are using $_SESSION (or $HTTP_SESSION_VARS), do not use
session_register(), session_is_registered(), and
session_unregister().
/manual


Curt
-- 
I used to think I was indecisive, but now I'm not so sure.

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



Re: [PHP] sessions failing to persist

2004-05-02 Thread Michael R. Wayne
On Mon, May 03, 2004 at 01:13:11AM -0400, John W. Holmes wrote:
 Michael R. Wayne wrote:
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
 
 Try adding in a hidden element
 
 input type=hidden name=PHPSESSID value=?=session_id();?
 
 You're relying on PHP rewriting your forms, links, etc, to include the 
 session id, but that doesn't seem to be happening.

I pasted that line just before the /form and the behaviour remains
unchanged.  No SessionId is never showing up in the access.log

/\/\ \/\/

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