Re: [PHP] Re: change value of session variable?

2004-07-22 Thread Five
Sounds like an old bug in PHP. What version are you using?

I've been trying to get it to work at:
http://members.lycos.co.uk/primeooze/info.php

I also have ( apache/php 4.3.4/mysql ) installed on my computer and I get much more 
satisfactory results on it.
I have made progress and some of my confusion on the subject has been cleared up so 
I'll just keep at  it and see what happens.

Thanks for your help

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



RE: [PHP] Re: change value of session variable?

2004-07-22 Thread Ford, Mike [LSS]
On 22 July 2004 07:50, Five wrote:

  Sounds like an old bug in PHP. What version are you using?
 
 I've been trying to get it to work at:
 http://members.lycos.co.uk/primeooze/info.php

According to this phpinfo(), that site has session.use_cookies=On and 
session.use_trans_sid=Off.  This means that the simple Blue/Green test that has been 
bandied about here won't work for anyone who is not accepting cookies.  Hence, John 
Holmes's question

  Are you sure you're accepting the cookie? How are you sure?

is extremely relevant.

 I also have ( apache/php 4.3.4/mysql ) installed on my
 computer and I get much more satisfactory results on it.

Does that installation have session.use_trans_sid=On?  If so, another of John's 
questions is relevant:

   If you see an SID in the URL when navigating the pages, does it stay the same 
between 
pages or change?

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



[PHP] Re: change value of session variable?

2004-07-21 Thread Harlequin
My understanding of session variables Five is that you can write and
re-write on the fly.

I know from using VB that this is true and I am assuming that it is true of
PHP. However, you may need to Empty the variable first Five.

Hope that helped.

-- 
-
 Michael Mason
 Arras People
 www.arraspeople.co.uk
-
Five [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Is it possible to assign a value to a session variable on say, page1.php:

 $_SESSION['favcolor'] = 'blue';

 and then on another page, say page2.php reassign the value:

 $_SESSION['favcolor'] = 'green'; ?

 So far experimentation says no.

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



[PHP] Re: change value of session variable?

2004-07-21 Thread Five
page1.php
?php
session_start();
echo 'page #1br';

echo $_SESSION['favcolor'];
$_SESSION['favcolor'] = 'green';

echo 'bra href=page2.phppage 2/a';
?


page2.php
?php
session_start();
echo 'page #2br';

echo $_SESSION['favcolor'];
$_SESSION['favcolor'] = 'blue';

echo 'bra href=page1.phppage 1/a';
?

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



[PHP] Re: change value of session variable?

2004-07-21 Thread Five

Five [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED]
 page1.php
 ?php
 session_start();
 echo 'page #1br';

 echo $_SESSION['favcolor'];
 $_SESSION['favcolor'] = 'green';

 echo 'bra href=page2.phppage 2/a';
 ?

 
 page2.php
 ?php
 session_start();
 echo 'page #2br';

 echo $_SESSION['favcolor'];
 $_SESSION['favcolor'] = 'blue';

 echo 'bra href=page1.phppage 1/a';
 ?

Actually the above code doesn't initialize the variable as either green or blue. It 
leaves it blank.

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



Re: [PHP] Re: change value of session variable?

2004-07-21 Thread Justin Patrin
On Wed, 21 Jul 2004 17:45:23 -0400, Five [EMAIL PROTECTED] wrote:
 page1.php
 ?php
 session_start();
 echo 'page #1br';
 
 echo $_SESSION['favcolor'];
 $_SESSION['favcolor'] = 'green';
 
 echo 'bra href=page2.phppage 2/a';
 ?
 
 
 page2.php
 ?php
 session_start();
 echo 'page #2br';
 
 echo $_SESSION['favcolor'];
 $_SESSION['favcolor'] = 'blue';
 
 echo 'bra href=page1.phppage 1/a';
 ?
 

So you go to page1.php and it has only a link.
You click the link to page2.php and you have 'green' and the link.
You click the link to page1.php and you have 'blue' and the link.

Is this not what happens?
-- 
DB_DataObject_FormBuilder - The database at your fingertips
http://pear.php.net/package/DB_DataObject_FormBuilder

paperCrane --Justin Patrin--

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



Re: [PHP] Re: change value of session variable?

2004-07-21 Thread Matt M.
what do you get when you print_r($_SESSION) ?

try session_write_close() at the end of your scripts.

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



Re: [PHP] Re: change value of session variable?

2004-07-21 Thread Justin Patrin
On Wed, 21 Jul 2004 17:50:36 -0400, Five [EMAIL PROTECTED] wrote:
 
 Five [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED]
  page1.php
  ?php
  session_start();
  echo 'page #1br';
 
  echo $_SESSION['favcolor'];
  $_SESSION['favcolor'] = 'green';
 
  echo 'bra href=page2.phppage 2/a';
  ?
 
  
  page2.php
  ?php
  session_start();
  echo 'page #2br';
 
  echo $_SESSION['favcolor'];
  $_SESSION['favcolor'] = 'blue';
 
  echo 'bra href=page1.phppage 1/a';
  ?
 
 Actually the above code doesn't initialize the variable as either green or blue. It 
 leaves it blank.
 

Are you behind any kind of firewall or proxy? Are you blocking
cookies? These could be stopping the session from working period.

You should have said that it wasn't working period. Your original
e-mail lead me to believe that it could be set initially.

-- 
DB_DataObject_FormBuilder - The database at your fingertips
http://pear.php.net/package/DB_DataObject_FormBuilder

paperCrane --Justin Patrin--

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



Re: [PHP] Re: change value of session variable?

2004-07-21 Thread Chris Shiflett
--- Five [EMAIL PROTECTED] wrote:
 page1.php
 ?php
 session_start();
 echo 'page #1br';

 echo $_SESSION['favcolor'];
 $_SESSION['favcolor'] = 'green';

 echo 'bra href=page2.phppage 2/a';
 ?

 
 page2.php
 ?php
 session_start();
 echo 'page #2br';

 echo $_SESSION['favcolor'];
 $_SESSION['favcolor'] = 'blue';

 echo 'bra href=page1.phppage 1/a';
 ?
 
 Actually the above code doesn't initialize the variable as
 either green or blue. It leaves it blank.

You might want to echo a variable after you set it (page1.php) or after
you change it (page2.php). :-)

Chris

=
Chris Shiflett - http://shiflett.org/

PHP Security - O'Reilly
 Coming Fall 2004
HTTP Developer's Handbook - Sams
 http://httphandbook.org/
PHP Community Site
 http://phpcommunity.org/

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



Re: [PHP] Re: change value of session variable?

2004-07-21 Thread Five

Justin Patrin [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED]
 On Wed, 21 Jul 2004 17:50:36 -0400, Five [EMAIL PROTECTED] wrote:
 
  Five [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED]
   page1.php
   ?php
   session_start();
   echo 'page #1br';
  
   echo $_SESSION['favcolor'];
   $_SESSION['favcolor'] = 'green';
  
   echo 'bra href=page2.phppage 2/a';
   ?
  
   
   page2.php
   ?php
   session_start();
   echo 'page #2br';
  
   echo $_SESSION['favcolor'];
   $_SESSION['favcolor'] = 'blue';
  
   echo 'bra href=page1.phppage 1/a';
   ?
 
  Actually the above code doesn't initialize the variable as either green or blue. 
  It leaves it blank.
 

 Are you behind any kind of firewall or proxy? Are you blocking
 cookies? These could be stopping the session from working period.

 You should have said that it wasn't working period. Your original
 e-mail lead me to believe that it could be set initially.

 -- 
 DB_DataObject_FormBuilder - The database at your fingertips
 http://pear.php.net/package/DB_DataObject_FormBuilder

 paperCrane --Justin Patrin--



The test code at

http://ca.php.net/manual/en/function.session-start.php

worked so I knew sessions were working to some extent.

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



Re: [PHP] Re: change value of session variable?

2004-07-21 Thread Five

Chris Shiflett [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED]
 --- Five [EMAIL PROTECTED] wrote:
  page1.php
  ?php
  session_start();
  echo 'page #1br';
 
  echo $_SESSION['favcolor'];
  $_SESSION['favcolor'] = 'green';
 
  echo 'bra href=page2.phppage 2/a';
  ?
 
  
  page2.php
  ?php
  session_start();
  echo 'page #2br';
 
  echo $_SESSION['favcolor'];
  $_SESSION['favcolor'] = 'blue';
 
  echo 'bra href=page1.phppage 1/a';
  ?
 
  Actually the above code doesn't initialize the variable as
  either green or blue. It leaves it blank.

 You might want to echo a variable after you set it (page1.php) or after
 you change it (page2.php). :-)

 Chris

 =
 Chris Shiflett - http://shiflett.org/

 PHP Security - O'Reilly
  Coming Fall 2004
 HTTP Developer's Handbook - Sams
  http://httphandbook.org/
 PHP Community Site
  http://phpcommunity.org/

That did it! I wonder if there is a way, then, to have it work even if the variable is 
initialized after it is echoed.
I was actually trying to do this to pass values in another script. I'm writing some 
code that has to do with storing and retrieving
images in mysql. I'm having trouble passing image information (the kind needed for 
getimagesize( ) to work) and I can't get session
variables to initalize in that either. More experimentation with echo (and other code) 
placement needed.

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



Re: [PHP] Re: change value of session variable?

2004-07-21 Thread Justin Patrin
On Wed, 21 Jul 2004 18:43:12 -0400, Five [EMAIL PROTECTED] wrote:
 
 Justin Patrin [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED]
 
 
  On Wed, 21 Jul 2004 17:50:36 -0400, Five [EMAIL PROTECTED] wrote:
  
   Five [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED]
page1.php
?php
session_start();
echo 'page #1br';
   
echo $_SESSION['favcolor'];
$_SESSION['favcolor'] = 'green';
   
echo 'bra href=page2.phppage 2/a';
?
   

page2.php
?php
session_start();
echo 'page #2br';
   
echo $_SESSION['favcolor'];
$_SESSION['favcolor'] = 'blue';
   
echo 'bra href=page1.phppage 1/a';
?
  
   Actually the above code doesn't initialize the variable as either green or blue. 
   It leaves it blank.
  
 
  Are you behind any kind of firewall or proxy? Are you blocking
  cookies? These could be stopping the session from working period.
 
  You should have said that it wasn't working period. Your original
  e-mail lead me to believe that it could be set initially.
 
  --
  DB_DataObject_FormBuilder - The database at your fingertips
  http://pear.php.net/package/DB_DataObject_FormBuilder
 
  paperCrane --Justin Patrin--
 
 
 The test code at
 
 http://ca.php.net/manual/en/function.session-start.php
 
 worked so I knew sessions were working to some extent.
 

Did you use the normal link or the SID link?

-- 
DB_DataObject_FormBuilder - The database at your fingertips
http://pear.php.net/package/DB_DataObject_FormBuilder

paperCrane --Justin Patrin--

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



Re: [PHP] Re: change value of session variable?

2004-07-21 Thread Five

Justin Patrin [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED]
 On Wed, 21 Jul 2004 18:43:12 -0400, Five [EMAIL PROTECTED] wrote:
 
  Justin Patrin [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED]
 
 
   On Wed, 21 Jul 2004 17:50:36 -0400, Five [EMAIL PROTECTED] wrote:
   
Five [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED]
 page1.php
 ?php
 session_start();
 echo 'page #1br';

 echo $_SESSION['favcolor'];
 $_SESSION['favcolor'] = 'green';

 echo 'bra href=page2.phppage 2/a';
 ?

 
 page2.php
 ?php
 session_start();
 echo 'page #2br';

 echo $_SESSION['favcolor'];
 $_SESSION['favcolor'] = 'blue';

 echo 'bra href=page1.phppage 1/a';
 ?
   
Actually the above code doesn't initialize the variable as either green or 
blue. It leaves it blank.
   
  
   Are you behind any kind of firewall or proxy? Are you blocking
   cookies? These could be stopping the session from working period.
  
   You should have said that it wasn't working period. Your original
   e-mail lead me to believe that it could be set initially.
  
   --
   DB_DataObject_FormBuilder - The database at your fingertips
   http://pear.php.net/package/DB_DataObject_FormBuilder
  
   paperCrane --Justin Patrin--
 
 
  The test code at
 
  http://ca.php.net/manual/en/function.session-start.php
 
  worked so I knew sessions were working to some extent.
 

 Did you use the normal link or the SID link?

 -- 
 DB_DataObject_FormBuilder - The database at your fingertips
 http://pear.php.net/package/DB_DataObject_FormBuilder

 paperCrane --Justin Patrin--


Both.

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



Re: [PHP] Re: change value of session variable?

2004-07-21 Thread Chris Shiflett
--- Five [EMAIL PROTECTED] wrote:
 That did it! I wonder if there is a way, then, to have it work even if
 the variable is initialized after it is echoed.

You see, that makes no sense, and that's why no one else was able to
answer your question. Code is executed in order. Consider this:

?php
$foo = 'one';
echo $foo;
$foo = 'two';
?

This script will output one, and it should. :-)

Chris

=
Chris Shiflett - http://shiflett.org/

PHP Security - O'Reilly
 Coming Fall 2004
HTTP Developer's Handbook - Sams
 http://httphandbook.org/
PHP Community Site
 http://phpcommunity.org/

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



Re: [PHP] Re: change value of session variable?

2004-07-21 Thread John W. Holmes
Chris Shiflett wrote:
--- Five [EMAIL PROTECTED] wrote:
That did it! I wonder if there is a way, then, to have it work even if
the variable is initialized after it is echoed.
You see, that makes no sense, and that's why no one else was able to
answer your question. Code is executed in order. Consider this:
Maybe some custom output buffer will make it work!? :)
--
---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] Re: change value of session variable?

2004-07-21 Thread Five

Chris Shiflett [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED]
 --- Five [EMAIL PROTECTED] wrote:
  That did it! I wonder if there is a way, then, to have it work even if
  the variable is initialized after it is echoed.

 You see, that makes no sense, and that's why no one else was able to
 answer your question. Code is executed in order. Consider this:

 ?php
 $foo = 'one';
 echo $foo;
 $foo = 'two';
 ?

 This script will output one, and it should. :-)


My problem isn't the logic of when and where to output variable values. It's figuring 
out when a session variable will accept
initialization and what enables and/or prevents it from doing so. I would like to be 
able to initialize a session variable on one
page, call a second page, have the code on the second page process some information 
and reinitialize the session variable to another
value so that new value could be available to be used on the first page. A lot like 
having a function return a value. The problem is
that the session variable won't accept a new value just any old where in the code on 
the second page (apparently.)

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



Re: [PHP] Re: change value of session variable?

2004-07-21 Thread Five

John W. Holmes [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED]
 Chris Shiflett wrote:

  --- Five [EMAIL PROTECTED] wrote:
 That did it! I wonder if there is a way, then, to have it work even if
 the variable is initialized after it is echoed.
 
  You see, that makes no sense, and that's why no one else was able to
  answer your question. Code is executed in order. Consider this:

 Maybe some custom output buffer will make it work!? :)

 -- 

 ---John Holmes...

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

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



Good idea. I'll look into that.

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



Re: [PHP] Re: change value of session variable?

2004-07-21 Thread Five
 The problem is
 that the session variable won't accept a new value just any old
where in the code on the second page (apparently.)

Or on the first one for that matter.

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



Re: [PHP] Re: change value of session variable?

2004-07-21 Thread Chris Shiflett
--- Five [EMAIL PROTECTED] wrote:
 My problem isn't the logic of when and where to output variable
 values. It's figuring out when a session variable will accept
 initialization and what enables and/or prevents it from doing so.

There's no magic. Session variables behave exactly like any other
variable. If you output a session variable before initializing it, you
will see nothing (and a notice is generated, depending on your
error_reporting setting).

The only difference, in terms of using session variables, is that they
persist from page to page.

 I would like to be able to initialize a session variable on one page,
 call a second page, have the code on the second page process some
 information and reinitialize the session variable to another value so
 that new value could be available to be used on the first page.

This is exactly what happens, although when you assign a variable a new
value, I wouldn't call it initializing, since the variable already exists.

Hope that helps.

Chris

=
Chris Shiflett - http://shiflett.org/

PHP Security - O'Reilly
 Coming Fall 2004
HTTP Developer's Handbook - Sams
 http://httphandbook.org/
PHP Community Site
 http://phpcommunity.org/

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



Re: [PHP] Re: change value of session variable?

2004-07-21 Thread Chris Shiflett
--- Five [EMAIL PROTECTED] wrote:
  Maybe some custom output buffer will make it work!? :)
 
  ---John Holmes...
 
 Good idea. I'll look into that.

He was kidding. :-)

Well, he was serious, in the sense that it could work, but he didn't mean
the suggestion to be taken seriously.

Chris

=
Chris Shiflett - http://shiflett.org/

PHP Security - O'Reilly
 Coming Fall 2004
HTTP Developer's Handbook - Sams
 http://httphandbook.org/
PHP Community Site
 http://phpcommunity.org/

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



Re: [PHP] Re: change value of session variable?

2004-07-21 Thread Five

Chris Shiflett [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED]
 --- Five [EMAIL PROTECTED] wrote:
  My problem isn't the logic of when and where to output variable
  values. It's figuring out when a session variable will accept
  initialization and what enables and/or prevents it from doing so.

 There's no magic. Session variables behave exactly like any other
 variable. If you output a session variable before initializing it, you
 will see nothing (and a notice is generated, depending on your
 error_reporting setting).

 The only difference, in terms of using session variables, is that they
 persist from page to page.


page1.php
?php
session_start();
echo 'page #1br';

echo $_SESSION['favcolor'];
$_SESSION['favcolor'] = 'green';

echo 'bra href=page2.phppage 2/a';
?


page2.php
?php
session_start();
echo 'page #2br';

echo $_SESSION['favcolor'];
$_SESSION['favcolor'] = 'blue';

echo 'bra href=page1.phppage 1/a';
?


When I tested the above example, no matter how many times I clicked back and forth 
between the two pages, the session variable would
not accept assignment of values 'blue' or 'green', while there should be no value on 
the first look at page1 but should have echoed
'green' on the first visit to page2 as that was the value it was assigned on page1.
When I changed the initialization and assignment of the session variable to before 
attempting to echo it's value, it then worked.
That started me thinking that placement of the initialization/assignment might make a 
difference on whether a session variable would
accept assignment of a value. An ordinary variable would have accepted assignment of a 
value after an attempt to echo it's value.

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



Re: [PHP] Re: change value of session variable?

2004-07-21 Thread John W. Holmes
Five wrote:

page1.php
?php
session_start();
echo 'page #1br';
echo $_SESSION['favcolor'];
$_SESSION['favcolor'] = 'green';
echo 'bra href=page2.phppage 2/a';
?

page2.php
?php
session_start();
echo 'page #2br';
echo $_SESSION['favcolor'];
$_SESSION['favcolor'] = 'blue';
echo 'bra href=page1.phppage 1/a';
?

This code works exactly the way it's supposed to!! No value first time, 
then rotating value!!

If it does not work for you, are you sure you're accepting the session 
cookie? How are you sure? Do you have a valid session.save_path? How do 
you know? Are you displaying errors? How do you know? If you see an SID 
in the URL when navigating the pages, does it stay the same between 
pages or change?

--
---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] Re: change value of session variable?

2004-07-21 Thread Justin Patrin
On Wed, 21 Jul 2004 22:42:40 -0400, Five [EMAIL PROTECTED] wrote:
 
 Chris Shiflett [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED]
  --- Five [EMAIL PROTECTED] wrote:
   That did it! I wonder if there is a way, then, to have it work even if
   the variable is initialized after it is echoed.
 
  You see, that makes no sense, and that's why no one else was able to
  answer your question. Code is executed in order. Consider this:
 
  ?php
  $foo = 'one';
  echo $foo;
  $foo = 'two';
  ?
 
  This script will output one, and it should. :-)
 
 
 My problem isn't the logic of when and where to output variable values. It's 
 figuring out when a session variable will accept
 initialization and what enables and/or prevents it from doing so. I would like to be 
 able to initialize a session variable on one
 page, call a second page, have the code on the second page process some information 
 and reinitialize the session variable to another
 value so that new value could be available to be used on the first page. A lot like 
 having a function return a value. The problem is
 that the session variable won't accept a new value just any old where in the code on 
 the second page (apparently.)
 

As said in earlier posts, it should have worked as you originally had
it. What version of PHP are you using? It's possible that there's a
bug.

-- 
DB_DataObject_FormBuilder - The database at your fingertips
http://pear.php.net/package/DB_DataObject_FormBuilder

paperCrane --Justin Patrin--

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



Re: [PHP] Re: change value of session variable?

2004-07-21 Thread Five

John W. Holmes [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED]
 Five wrote:
  
  page1.php
  ?php
  session_start();
  echo 'page #1br';
 
  echo $_SESSION['favcolor'];
  $_SESSION['favcolor'] = 'green';
 
  echo 'bra href=page2.phppage 2/a';
  ?
 
  
  page2.php
  ?php
  session_start();
  echo 'page #2br';
 
  echo $_SESSION['favcolor'];
  $_SESSION['favcolor'] = 'blue';
 
  echo 'bra href=page1.phppage 1/a';
  ?
  

 This code works exactly the way it's supposed to!! No value first time,
 then rotating value!!

 If it does not work for you, are you sure you're accepting the session
 cookie? How are you sure? Do you have a valid session.save_path? How do
 you know? Are you displaying errors? How do you know? If you see an SID
 in the URL when navigating the pages, does it stay the same between
 pages or change?


 -- 

 ---John Holmes...

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

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

If you had read my replies you would know how I know.
And, oh yeah, if you're not a troll, how would I know?

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



Re: [PHP] Re: change value of session variable?

2004-07-21 Thread Justin Patrin
On Thu, 22 Jul 2004 00:48:16 -0400, Five [EMAIL PROTECTED] wrote:
 
 Chris Shiflett [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED]
  --- Five [EMAIL PROTECTED] wrote:
   My problem isn't the logic of when and where to output variable
   values. It's figuring out when a session variable will accept
   initialization and what enables and/or prevents it from doing so.
 
  There's no magic. Session variables behave exactly like any other
  variable. If you output a session variable before initializing it, you
  will see nothing (and a notice is generated, depending on your
  error_reporting setting).
 
  The only difference, in terms of using session variables, is that they
  persist from page to page.
 
 
 page1.php
 ?php
 session_start();
 echo 'page #1br';
 
 echo $_SESSION['favcolor'];
 $_SESSION['favcolor'] = 'green';
 
 echo 'bra href=page2.phppage 2/a';
 ?
 
 
 page2.php
 ?php
 session_start();
 echo 'page #2br';
 
 echo $_SESSION['favcolor'];
 $_SESSION['favcolor'] = 'blue';
 
 echo 'bra href=page1.phppage 1/a';
 ?
 
 
 When I tested the above example, no matter how many times I clicked back and forth 
 between the two pages, the session variable would
 not accept assignment of values 'blue' or 'green', while there should be no value on 
 the first look at page1 but should have echoed
 'green' on the first visit to page2 as that was the value it was assigned on page1.
 When I changed the initialization and assignment of the session variable to before 
 attempting to echo it's value, it then worked.
 That started me thinking that placement of the initialization/assignment might make 
 a difference on whether a session variable would
 accept assignment of a value. An ordinary variable would have accepted assignment of 
 a value after an attempt to echo it's value.
 

It's still an ordinary variable. Sounds like an old bug in PHP. What
version are you using? I promise that I am doing things just like
that, only with no output at all of the session var, and it works
fine.

-- 
DB_DataObject_FormBuilder - The database at your fingertips
http://pear.php.net/package/DB_DataObject_FormBuilder

paperCrane --Justin Patrin--

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



Re: [PHP] Re: change value of session variable?

2004-07-21 Thread John W. Holmes
Five wrote:
John W. Holmes [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED]

If it does not work for you, are you sure you're accepting the session
cookie? How are you sure? Do you have a valid session.save_path? How do
you know? Are you displaying errors? How do you know? If you see an SID
in the URL when navigating the pages, does it stay the same between
pages or change?

If you had read my replies you would know how I know.
And, oh yeah, if you're not a troll, how would I know?
Answer the questions if you want help.
--
---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] Re: change value of session variable?

2004-07-21 Thread Jason Wong
On Thursday 22 July 2004 13:14, Five wrote:

 If you had read my replies you would know how I know.
 And, oh yeah, if you're not a troll, how would I know?

Could you please trim your posts?

Your code as it stands *should* work. YOU have not been able to get it to work 
so you was given a perfectly sensible list of things to check. Are you on 
this list looking for help or what?

-- 
A. T. Roll

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