Hi Bill,
I tried the 2 pages here:
http://circlecity.co.uk/testarea/test.php
The 1st page passes the session id and user ok.

In the 2nd page you're echoing the same values before and after the form.
The form is calling itself, so these 2 values won't alter.
It seems to be working ok.

p.s. when passing the SID it's recommended to use:
<?php echo strip_tags(SID); ?>
but this wouldn't cure your problem.

Bob E.


----- Original Message ----- 
From: "new_wave_photo" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Sunday, March 26, 2006 6:49 PM
Subject: [php-list] The Missing Session Variable


Hello,

I have a little problem.  I have been writing some programs using 
PHP.  All of them use "sessions".  Many use "session variables".  One 
day the programs are working fine.  The next day – puff.  Nothing 
works.  I've done some testing and I believe I have narrowed the 
problem down.  It seems that the "session variables" are being lost 
after a <FORM> is submitted.  Below are the scripts from two simple 
programs which I believe illustrate my problem.  Any help would be 
greatly appreciated……..Bill  

Below are two scripts – two distinct files.   The first one simply 
sets the session variable and branches to the second file.  Please 
understand that all the <HTML> and <BODY> statements are present but 
have been eliminated from here to save space.

------- first script or file begins here ---------
<?
session_start();
$_SESSION['user']="Confused";
echo("<CENTER>Session_id: ".session_id());
echo("<BR>User: ".$_SESSION['user']);
?>
<BR><A HREF='http://newwavephotog.com/Programs/test_SID02.php?<?php 
echo(SID);?>'>Next Page</A><BR></CENTER>
-------  end of first script or file -------

Below is the second script which is called above.  It is 
called  "test_SID02.php".  The first set of "echos" show that the SID 
has been passed from the previous script  and  that the session 
variable is set.  Eveything looks good until I press the "submit" key 
for the form.  After I click on the "submit" key, all the "echo" 
statements indicate that SID has been changed and that the session 
variable is blank.  Nada.   Zero.  El Disapeero.  Why?

------ second script or file begins here -----------
<?
session_start();
/*
   first set of echos
*/
echo("<CENTER>Session_id: ".session_id());
echo("<BR>User: ".$_SESSION['user']);
$self=$_SERVER['PHP_SELF'];

?>
<BR>
<FORM action="<?php echo($self);?>" method="POST">
<input type='TEXT' name='testing'>
<input type='submit' name='submit' value='TEST'>
</FORM><BR>
<?php
/*
  second set of echos
*/
echo("Session_id: ".session_id()."<BR>");
echo("<BR>New Session: ".$_SESSION['user']);

?>





Community email addresses:
  Post message: [email protected]
  Subscribe:    [EMAIL PROTECTED]
  Unsubscribe:  [EMAIL PROTECTED]
  List owner:   [EMAIL PROTECTED]

Shortcut URL to this page:
  http://groups.yahoo.com/group/php-list 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/php-list/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to