[PHP] $_SESSION var sometimes set, sometimes not

2003-11-24 Thread Anthony Whipple
Hi,

The following code sometimes produces output indicating that the session
variables have been set, and sometimes is says that they have not been set.
Unfortunately the server is not mine to configure, but if there is a problem
with it, I can get in touch with the right people.  Is the script properly
written?  Is it a server problem?


html
head
 titleTest stuff.../title
/head
body

?php
session_start(); // enable session level global variables

if (isset($_POST['action'])  $_POST['action'] == 'sub1' ) sub1();
else {
session_unset(); // all variables start fresh here
$_SESSION['test']='HERE I AM!br';
echo $_SESSION['test'];
print_r ($_SESSION);
}

function sub1()
{
echo sub1 routinebr;
print_r ($_SESSION);
if ( isset($_SESSION['test']) )
echo $_SESSION['test'];
else
echo 'variable not setbr';
}


///
?

form action=?php echo $_SERVER['PHP_SELF']; ? method=POST
select name=sub1
option sub1 /optionbr
/select
input type=hidden name=action value=sub1
input type=submit name=submit value=go
/form

/body
/html

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



Re: [PHP] $_SESSION var sometimes set, sometimes not

2003-11-24 Thread Anthony Whipple
I just tried that.  It made no change.  Still sometimes works, sometimes
doesn't.  It's on the order of clicks.  It may work three times in a row,
then fail a couple times.  It's very strange.

John W. Holmes [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Anthony Whipple wrote:

  The following code sometimes produces output indicating that the session
  variables have been set, and sometimes is says that they have not been
set.
  Unfortunately the server is not mine to configure, but if there is a
problem
  with it, I can get in touch with the right people.  Is the script
properly
  written?  Is it a server problem?
 
  html
  head
   titleTest stuff.../title
  /head
  body
 
  ?php
  session_start(); // enable session level global variables

 This shouldn't work at all. You need to have session_start() before any
 HTML or output. The beginning of your file should be

 ?php session_start(); ?
 html
 ...

 -- 
 ---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