Re: [PHP] $HTTP_SESSION_VARS still holds original values even after unset?

2004-04-04 Thread John Holmes
Andy B wrote:
how would you empty all the contents of 
 $HTTP_SESSION_VARS when you dont need
 them anymore but still keep the current
 session running?
$HTTP_SESSION_VARS = array();

---John Holmes...

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


RE: [PHP] $HTTP_SESSION_VARS still holds original values even after unset?

2004-04-04 Thread Larry Brown
Something else in your code is messing you up if you cannot change the value
after setting it in the first place.  This happens all the time in my code
as my client makes decisions along the way.  Try a small test creating a
session variable, displaying it, changing it, and redisplaying it.  If it
does not show the change, post the test code so we might be able to tell why
it fails.

Provided you can change the variable, you should be able to create a loop
that sets all the variables to  or some base values etc.

Larry

-Original Message-
From: Andy B [mailto:[EMAIL PROTECTED]
Sent: Sunday, April 04, 2004 6:03 PM
To: [EMAIL PROTECTED]
Subject: [PHP] $HTTP_SESSION_VARS still holds original values even after
unset?


how would you empty all the contents of $HTTP_SESSION_VARS when you dont
need them anymore but still keep the current session running? the problem
seems to be that when i try to fill them with something else (dont need the
original values anymore) but need new ones without destroying the session
itself they wont fill with new things. unset($HTTP_SESSION_VARS); does
nothing to help at all because they still have the same values that they
were originally filled with (and not to mention they are still in the
session)...

anybody have any ideas how to delete or empty out the array but keep the
session active ??

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



Re: [PHP] $HTTP_SESSION_VARS still holds original values even after unset?

2004-04-04 Thread trlists
On 4 Apr 2004 Andy B wrote:

 how would you empty all the contents of $HTTP_SESSION_VARS when you
 dont need them anymore but still keep the current session running?

See http://www.php.net/manual/en/function.session-unset.php.  That is 
exactly what it does.  That page also explains why unset() is not the 
right way to go.

--
Tom

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



Re: [PHP] http_session_vars

2003-03-14 Thread rotsky
Aaah! That clears something up. Thanks.

Ernest E Vogelsinger [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 At 22:17 13.03.2003, rotsky said:
 [snip]
 I thought session vars were either POSTed or passed via cookies...
 [snip]

 No - you're mixing up the session identifier and session data.

 The session identifier is just an arbitrary key to a server-side storage
 where session data is stored. The session identifier (aka SID) is
 effectively passed either via cookie, or via $_REQUEST parameter.

 Session data (the $_SESSION array, to be specific) will always be stored
 server-side, by default in a session file. The default filename is
sess_SID.


 --
O Ernest E. Vogelsinger
(\)ICQ #13394035
 ^ http://www.vogelsinger.at/





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



Re: [PHP] http_session_vars

2003-03-13 Thread CPT John W. Holmes
 do the session vars get treated with magic quotes? The last comment at the
bottom of:

 http://www.php.net/manual/en/function.get-magic-quotes-gpc.php

 Seems to think so. He's  written good code, but I have my doubts as to
whether it should be applied
 to session vars.

The gpc stands for GET, POST, and COOKIE. So I'm going to say No.

---John Holmes...


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



Re: [PHP] http_session_vars

2003-03-13 Thread rotsky
I thought session vars were either POSTed or passed via cookies...

Cpt John W. Holmes [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
  do the session vars get treated with magic quotes? The last comment at
the
 bottom of:
 
  http://www.php.net/manual/en/function.get-magic-quotes-gpc.php
 
  Seems to think so. He's  written good code, but I have my doubts as to
 whether it should be applied
  to session vars.

 The gpc stands for GET, POST, and COOKIE. So I'm going to say No.

 ---John Holmes...




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



Re: [PHP] http_session_vars

2003-03-13 Thread Ernest E Vogelsinger
At 22:17 13.03.2003, rotsky said:
[snip]
I thought session vars were either POSTed or passed via cookies...
[snip] 

No - you're mixing up the session identifier and session data.

The session identifier is just an arbitrary key to a server-side storage
where session data is stored. The session identifier (aka SID) is
effectively passed either via cookie, or via $_REQUEST parameter.

Session data (the $_SESSION array, to be specific) will always be stored
server-side, by default in a session file. The default filename is sess_SID.


-- 
   O Ernest E. Vogelsinger
   (\)ICQ #13394035
^ http://www.vogelsinger.at/



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



Re: [PHP] $HTTP_SESSION_VARS vs $_SESSION - cont.

2002-08-14 Thread Analysis Solutions

On Tue, Aug 13, 2002 at 10:07:57AM -0700, Rasmus Lerdorf wrote:
   while ( list($Key, $Val) = each($_SESSION) ) {
  $$Key = $Val;
   }
 
 extract($_SESSION) is a better way to do that.

Yeah.  Old habits die hard! :)

--Dan

-- 
   PHP classes that make web design easier
SQL Solution  |   Layout Solution   |  Form Solution
sqlsolution.info  | layoutsolution.info |  formsolution.info
 T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409

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




Re: [PHP] $HTTP_SESSION_VARS vs $_SESSION - cont.

2002-08-13 Thread Petre Agenbag

Rasmus
OK, I think I understand the principle now, yet, when I implement id, my
app still fails.
I have register_golbals = on, BUT, I want to find a way to code that I
know will always work, regardless of register_globals or cookies, so
that I am only dependant on the trans-sid ( but If I could rule that out
too, it would be even better)

How do you write your apps so you know that they will work on most
configurations? I have a bunch of older apps that will definately break
if I upgrade the server and turn register_globals off, and I want to
prevent it from happening with new apps I write now.


With what you said below, can I assume that:
1) If I know all the variables that I will need to be session variables,
I can session_register() them all on the first page, and then simply
give them values during the normal flow of the app?

I have tried to implement what you said below in my app as follow,
basically the route is:
Login form -- action page:
action page links to another form page
form page -- action page

All these pages are supposed to be part of the session, but between the
last two pages, the session disappears, and the form doesn't pass
variables...

I'm so utterly fed-up with myself for not being able to get this right. 
Can you see ANYTHING that might cause this?


index.php
?php
session_start();
?

form name=form1 method=post action=admin_select.php
  table border=0 cellspacing=0 cellpadding=0
tr bgcolor=#CFCFCF
  td colspan=2Admin Login
  /td
/tr
tr
  tdUsername:
  /td
  tdinput type=text name=user_name 
  /td
/tr
tr
  tdPassword:
  /td
  tdinput type=text name=pass_word 
  /td
/tr
tr
  td
input type=submit name=Submit4 value=Submit
  /td
/tr
  /table
/form

Then: 
admin_select.php

?php
session_start();
if ((!$HTTP_SESSION_VARS[username]) 
(!$HTTP_SESSION_VARS[password])) {
session_register(username,password);
}
if (($HTTP_POST_VARS[user_name])  ($HTTP_POST_VARS[pass_word])) {

$username =  $HTTP_POST_VARS[user_name];
$password =  $HTTP_POST_VARS[pass_word];

}
/* Not sure if my logic above works, trying to check if the person is
coming back via a link or from the from for the first time; I'm not sure
what could happen if you session_register a variable twice??? */

$link = mysql_connect(localhost,$username,$password) or die
('Could not connect!');
mysql_select_db(mafisa,$link);
$sql = select * from project_table order by id;
$result = mysql_query($sql);
?
 form action=admin_select_document.php method=POST
enctype=multipart/form-data
  table border=1
  tr
td colspan=2 bgcolor=CFCFCFAdmin Interface/td
  /tr
  tr
td colspan=2Please select Project to work with/td
  /tr
  tr
td colspan =2
?php
if (mysql_num_rows($result)) {
echo select name=\sess_id_project\;
while ($myrow = mysql_fetch_assoc($result)) {
$sess_project_name = $myrow[project_name];
$sess_project_id = $myrow[id];
echo 'option
value='.$sess_project_id.''.$sess_project_name;
}
echo '/select';
echo '/td';
echo '/tr';
echo 'tr';
echo 'td colspan=2input type=submit name=submit 
value=Go!/td';
echo '/tr';
echo '/form';
} else {
echo 'biThere are currently no Projects on the system,';
echo 'please use the section below to add one/i/b';
echo '/td';
echo '/tr';
echo '/form';
}


echo 'trtd colspan=2 bgcolor=00/td/tr

  tr
td colspan=2 bgcolor=CFCFCFa href=admin_add_project.phpAdd
a new Project/a/td
  /tr

/table';

?


This second page has two routes to go, either you select the document
from the drop_down, or you can add a new project, It is with the
second route that I pick up further problems:

admin_add_project.php

?php
 session_start();
echo '
form action=admin_add_project_do.php method=POST
enctype=multipart/form-data
  table
  tr
td colspan=2 bgcolor=CFCFCFMafisa Admin Interface/td
  /tr
  tr
tdNew Project Name/td
tdinput type=text name=project_name_add/td
  /tr
  tr
tdProject Descriptions/td
tdtextarea name=project_description_add/textarea/td
  /tr
  tr
td colspan=2input type=submit name=submit
value=Save/td
  /tr
/table
/form
';
?

Now, on this last page that is supposed to insert the form data into the
db, there is simply no form data, or session variables!

admin_add_project_do.php
?php
session_start();
$date = date('Y-m-d');
$link =
mysql_connect('localhost',$HTTP_SESSION_VARS[username],$HTTP_SESSION_VARS[password])
 or die ('Could not connect!');
mysql_select_db('mafisa',$link);
$project_name_db =
addslashes($HTTP_POST_VARS[project_name_add]);
$project_description_db =

Re: [PHP] $HTTP_SESSION_VARS vs $_SESSION - cont.

2002-08-13 Thread Analysis Solutions

Petre:

On Tue, Aug 13, 2002 at 03:18:42PM +0200, Petre Agenbag wrote:

 I have register_golbals = on, BUT, I want to find a way to code that I
 know will always work, regardless of register_globals or cookies, so
 that I am only dependant on the trans-sid ( but If I could rule that out
 too, it would be even better)

This example assumes the machine is running PHP = 4.1.0 allowing use of
$_SESSION rather than $HTTP_SESSION_VARS.  Adjust as needed.

  session_start();

  if ( !isset($SessionID) ) {
 #  This likely means that register globals is off.
 #  So, loop through the session vars and create regular vars.
 while ( list($Key, $Val) = each($_SESSION) ) {
$$Key = $Val;
 }
  }

Enjoy,

--Dan

-- 
   PHP classes that make web design easier
SQL Solution  |   Layout Solution   |  Form Solution
sqlsolution.info  | layoutsolution.info |  formsolution.info
 T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409

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




Re: [PHP] $HTTP_SESSION_VARS vs $_SESSION - cont.

2002-08-13 Thread Rasmus Lerdorf

No real reason to start the session in index.php.  You are not registering
any session vars, nor are you accessing any.

 index.php
 ?php
   session_start();
 ?

 form name=form1 method=post action=admin_select.php
   table border=0 cellspacing=0 cellpadding=0
 tr bgcolor=#CFCFCF
   td colspan=2Admin Login
   /td
 /tr
 tr
   tdUsername:
   /td
   tdinput type=text name=user_name 
   /td
 /tr
 tr
   tdPassword:
   /td
   tdinput type=text name=pass_word 
   /td
 /tr
 tr
   td
 input type=submit name=Submit4 value=Submit
   /td
 /tr
   /table
 /form

Ok, now that we are in admin_select.php you can start the session, which
you do.

 Then:
 admin_select.php

 ?php
 session_start();
 if ((!$HTTP_SESSION_VARS[username]) 
 (!$HTTP_SESSION_VARS[password])) {
 session_register(username,password);
 }
   if (($HTTP_POST_VARS[user_name])  ($HTTP_POST_VARS[pass_word])) {

 $username =  $HTTP_POST_VARS[user_name];
 $password =  $HTTP_POST_VARS[pass_word];
   }

Looks ok so far.  Although I am not sure session_register() was able to
take multiple args in 4.0.3.  But you don't need the check.  Nothing bad
happens if you session_register() the same var twice.

 $link = mysql_connect(localhost,$username,$password) or die
 ('Could not connect!');
 mysql_select_db(mafisa,$link);
 $sql = select * from project_table order by id;
 $result = mysql_query($sql);
 ?
  form action=admin_select_document.php method=POST
 enctype=multipart/form-data
   table border=1
   tr
 td colspan=2 bgcolor=CFCFCFAdmin Interface/td
   /tr
   tr
 td colspan=2Please select Project to work with/td
   /tr
   tr
 td colspan =2
 ?php
 if (mysql_num_rows($result)) {
   echo select name=\sess_id_project\;
   while ($myrow = mysql_fetch_assoc($result)) {
   $sess_project_name = $myrow[project_name];
   $sess_project_id = $myrow[id];
   echo 'option
 value='.$sess_project_id.''.$sess_project_name;
   }
 echo '/select';
 echo '/td';
 echo '/tr';
 echo 'tr';
 echo 'td colspan=2input type=submit name=submit
 value=Go!/td';
 echo '/tr';
 echo '/form';
 } else {
 echo 'biThere are currently no Projects on the system,';
   echo 'please use the section below to add one/i/b';
 echo '/td';
 echo '/tr';
 echo '/form';
 }


 echo 'trtd colspan=2 bgcolor=00/td/tr

   tr
 td colspan=2 bgcolor=CFCFCFa href=admin_add_project.phpAdd
 a new Project/a/td
   /tr

 /table';

 ?

ok

 This second page has two routes to go, either you select the document
 from the drop_down, or you can add a new project, It is with the
 second route that I pick up further problems:

 admin_add_project.php

 ?php
  session_start();
 echo '
 form action=admin_add_project_do.php method=POST
 enctype=multipart/form-data
   table
   tr
 td colspan=2 bgcolor=CFCFCFMafisa Admin Interface/td
   /tr
   tr
 tdNew Project Name/td
 tdinput type=text name=project_name_add/td
   /tr
   tr
 tdProject Descriptions/td
 tdtextarea name=project_description_add/textarea/td
   /tr
   tr
 td colspan=2input type=submit name=submit
 value=Save/td
   /tr
 /table
 /form
 ';
 ?

Again, you don't register nor do you use any session vars in
admin_add_project.php so there is no need to start the session.

 Now, on this last page that is supposed to insert the form data into the
 db, there is simply no form data, or session variables!

 admin_add_project_do.php
 ?php
 session_start();
 $date = date('Y-m-d');
 $link =
 
mysql_connect('localhost',$HTTP_SESSION_VARS[username],$HTTP_SESSION_VARS[password])
 or die ('Could not connect!');
 mysql_select_db('mafisa',$link);
 $project_name_db =
 addslashes($HTTP_POST_VARS[project_name_add]);
 $project_description_db =
 addslashes($HTTP_POST_VARS[project_description_add]);
 $sql = insert into project_table
 (project_name,project_description,date) values
 ('$project_name_db','$project_description_db','$date');
 $result = mysql_query($sql);
 echo 'Thank you, new project ::
 bi'.$project_name_db.'/i/b was added to the system. br
a href=admin_select.phpBack/abr';
 ?

Looks ok.  Is it only on 4.0.3 that this isn't working?

Why don't you do this instead at the top of each page where you want to
use the session vars:

 if(!ini_get('register_globals')) {
 extract($HTTP_SESSION_VARS);
 }

Then just use plain $username and $password.  See if that makes a
difference.  But you really should get your provider to upgrade to
something a lot more recent than 4.0.3.  Do you realize that 4.0.3 is
almost 2 years old now?  That's an eternity on the Web.

-Rasmus


-- 
PHP General Mailing List 

Re: [PHP] $HTTP_SESSION_VARS vs $_SESSION - cont.

2002-08-13 Thread Rasmus Lerdorf

  while ( list($Key, $Val) = each($_SESSION) ) {
 $$Key = $Val;
  }

extract($_SESSION) is a better way to do that.

-Rasmus


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




Re: [PHP] $HTTP_SESSION_VARS vs $_SESSION

2002-08-12 Thread Rasmus Lerdorf

If register_globals is known to be on, why are you worrying about
the $HTTP_* arrays?

On 12 Aug 2002, Petre Agenbag wrote:

 Hi
 Me again

 Still having problems with forms not sending variables, and session
 variables dissapearing.

 I have 2 systems, one older 4.0.3 PHP which is my main webserver, so all
 scripts must comply with it...
 And the other my development server with the latest 4.1.2

 So, I'm trying to write scripts that will happily work on both, and I
 understand that I must use HTTP_POST_VARS and HTTP_SESSION_VARS in order
 to comply with 4.0.3.

 register_globals and track_vars as well as trans_sid are enabled on
 both.

 Now, take a look at the example below:
 index.php

 form action=page2.php method=POST 
   input type=text name=testinput type=submit name=submit
 /form


 page2.php

 ?php
 session_start();
 echo ' HTTP_POST_VARS :'.$HTTP_POST_VARS[test].'br';
 echo ' POST_VARS: '.$_POST[test].'br';
 echo ' normal test :'.$test.'br';
 echo 'Session Value (only for
 re-entry):'.$HTTP_SESSION_VARS[testing].'br';

 if ($HTTP_POST_VARS[test]) {
 $HTTP_SESSION_VARS[testing] = $HTTP_POST_VARS[test];
 }
 echo 'a href=page3.phpClick/a';
 ?

 page3.php

 ?php
 session_start();
 echo 'Session Variable:'.$HTTP_SESSION_VARS[testing].'br';
 echo 'a href=page4.phpForward to test sess var further/abr';
 echo 'a href=page2.phpBack to test sess var/abr';
 ?

 page4.php

 ?php
 session_start();
 echo 'Session Variable:'.$HTTP_SESSION_VARS[testing].'br';
 echo 'a href=page3.phpBack to page 3 to test sess var
 further/abr';
 echo 'a href=page2.phpBack to page 2 to test sess var/abr';
 ?

 This small test works 100% on my newer system, and I was under the
 impression that I coded it to be backwards compatible with my older
 system, BUT,

 look here: http://www.linuxhelp.co.za/session_test to see what it does
 on my working server. The scripts are identical.

 Please can you point out my mistakes in reasoning?

 Also, I want these scripts to work regardless of cookies, so if you see
 something that might cause problems when ppl disable cookies, plz
 advise.



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



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




Re: [PHP] $HTTP_SESSION_VARS vs $_SESSION

2002-08-12 Thread Petre Agenbag

You lost me there...
Are you saying I don't need to access those variable in that way?
Can I simply use $variable in successive pages then?
Surely I MUST use that notation to assign values then right?, specially
to the session vars, right?

But, just out of curiosity, why does it work fine on my newer system?

Thanks

On Mon, 2002-08-12 at 21:17, Rasmus Lerdorf wrote:
 If register_globals is known to be on, why are you worrying about
 the $HTTP_* arrays?
 
 On 12 Aug 2002, Petre Agenbag wrote:
 
  Hi
  Me again
 
  Still having problems with forms not sending variables, and session
  variables dissapearing.
 
  I have 2 systems, one older 4.0.3 PHP which is my main webserver, so all
  scripts must comply with it...
  And the other my development server with the latest 4.1.2
 
  So, I'm trying to write scripts that will happily work on both, and I
  understand that I must use HTTP_POST_VARS and HTTP_SESSION_VARS in order
  to comply with 4.0.3.
 
  register_globals and track_vars as well as trans_sid are enabled on
  both.
 
  Now, take a look at the example below:
  index.php
 
  form action=page2.php method=POST 
input type=text name=testinput type=submit name=submit
  /form
 
 
  page2.php
 
  ?php
  session_start();
  echo ' HTTP_POST_VARS :'.$HTTP_POST_VARS[test].'br';
  echo ' POST_VARS: '.$_POST[test].'br';
  echo ' normal test :'.$test.'br';
  echo 'Session Value (only for
  re-entry):'.$HTTP_SESSION_VARS[testing].'br';
 
  if ($HTTP_POST_VARS[test]) {
  $HTTP_SESSION_VARS[testing] = $HTTP_POST_VARS[test];
  }
  echo 'a href=page3.phpClick/a';
  ?
 
  page3.php
 
  ?php
  session_start();
  echo 'Session Variable:'.$HTTP_SESSION_VARS[testing].'br';
  echo 'a href=page4.phpForward to test sess var further/abr';
  echo 'a href=page2.phpBack to test sess var/abr';
  ?
 
  page4.php
 
  ?php
  session_start();
  echo 'Session Variable:'.$HTTP_SESSION_VARS[testing].'br';
  echo 'a href=page3.phpBack to page 3 to test sess var
  further/abr';
  echo 'a href=page2.phpBack to page 2 to test sess var/abr';
  ?
 
  This small test works 100% on my newer system, and I was under the
  impression that I coded it to be backwards compatible with my older
  system, BUT,
 
  look here: http://www.linuxhelp.co.za/session_test to see what it does
  on my working server. The scripts are identical.
 
  Please can you point out my mistakes in reasoning?
 
  Also, I want these scripts to work regardless of cookies, so if you see
  something that might cause problems when ppl disable cookies, plz
  advise.
 
 
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 


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




Re: [PHP] $HTTP_SESSION_VARS vs $_SESSION

2002-08-12 Thread Petre Agenbag

Oh, almost forgot,
I *think* the reason why I'm still worrying about the $HTTP_* arrays are
because I *think* that it is the correct way to work with the vars once
register_globals is turned off ( which is where things are moving to
right?), and I don't want to re-code my scripts... 
Am I making sense?

On Mon, 2002-08-12 at 21:17, Rasmus Lerdorf wrote:
 If register_globals is known to be on, why are you worrying about
 the $HTTP_* arrays?
 
 On 12 Aug 2002, Petre Agenbag wrote:
 
  Hi
  Me again
 
  Still having problems with forms not sending variables, and session
  variables dissapearing.
 
  I have 2 systems, one older 4.0.3 PHP which is my main webserver, so all
  scripts must comply with it...
  And the other my development server with the latest 4.1.2
 
  So, I'm trying to write scripts that will happily work on both, and I
  understand that I must use HTTP_POST_VARS and HTTP_SESSION_VARS in order
  to comply with 4.0.3.
 
  register_globals and track_vars as well as trans_sid are enabled on
  both.
 
  Now, take a look at the example below:
  index.php
 
  form action=page2.php method=POST 
input type=text name=testinput type=submit name=submit
  /form
 
 
  page2.php
 
  ?php
  session_start();
  echo ' HTTP_POST_VARS :'.$HTTP_POST_VARS[test].'br';
  echo ' POST_VARS: '.$_POST[test].'br';
  echo ' normal test :'.$test.'br';
  echo 'Session Value (only for
  re-entry):'.$HTTP_SESSION_VARS[testing].'br';
 
  if ($HTTP_POST_VARS[test]) {
  $HTTP_SESSION_VARS[testing] = $HTTP_POST_VARS[test];
  }
  echo 'a href=page3.phpClick/a';
  ?
 
  page3.php
 
  ?php
  session_start();
  echo 'Session Variable:'.$HTTP_SESSION_VARS[testing].'br';
  echo 'a href=page4.phpForward to test sess var further/abr';
  echo 'a href=page2.phpBack to test sess var/abr';
  ?
 
  page4.php
 
  ?php
  session_start();
  echo 'Session Variable:'.$HTTP_SESSION_VARS[testing].'br';
  echo 'a href=page3.phpBack to page 3 to test sess var
  further/abr';
  echo 'a href=page2.phpBack to page 2 to test sess var/abr';
  ?
 
  This small test works 100% on my newer system, and I was under the
  impression that I coded it to be backwards compatible with my older
  system, BUT,
 
  look here: http://www.linuxhelp.co.za/session_test to see what it does
  on my working server. The scripts are identical.
 
  Please can you point out my mistakes in reasoning?
 
  Also, I want these scripts to work regardless of cookies, so if you see
  something that might cause problems when ppl disable cookies, plz
  advise.
 
 
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 


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




Re: [PHP] $HTTP_SESSION_VARS vs $_SESSION

2002-08-12 Thread Rasmus Lerdorf

No, you don't need to use HTTP_SESSION_VARS for anything if
register_globals is on.  Sessions are very simple.  You start a session,
and you register variables to be part of that session.  Like this:

 session_start();
 session_register('a');
 session_register('b');

If you have that at the top of the first page, then whatever values $a and
$b have by the time the script finishes is what will be written to the
session backend.

So, on a subsequent page you just do:

 session_start();

This will see the session ID that the browser passed to it either via a
cookie or in the URL and it will go and restore the variables from the
session backend.  That means that at this point you can just do:

 echo $a;
 echo $b;

At no point is there any need for $HTTP_SESSION_VARS nor $_SESSION if you
are sure that register_globals will always be on.

Now, if you want it to work with register_globals off, you still don't
need to use $HTTP_SESSION_VARS when setting the variables, you only need
to use it when retrieving them.  So, instead of echo $a and echo $b you
would have:

 echo $HTTP_SESSION_VARS['a'];
 echo $HTTP_SESSION_VARS['b'];

Or, of course in newer PHP's you can use $_SESSION['a'].

Your stuff probably didn't work because you were setting the session vars
via the $HTTP_SESSION_VARS array.  That works now, but it probably didn't
use to as it is a bit of a weird way to do it.

-Rasmus

On 12 Aug 2002, Petre Agenbag wrote:

 You lost me there...
 Are you saying I don't need to access those variable in that way?
 Can I simply use $variable in successive pages then?
 Surely I MUST use that notation to assign values then right?, specially
 to the session vars, right?

 But, just out of curiosity, why does it work fine on my newer system?

 Thanks

 On Mon, 2002-08-12 at 21:17, Rasmus Lerdorf wrote:
  If register_globals is known to be on, why are you worrying about
  the $HTTP_* arrays?
 
  On 12 Aug 2002, Petre Agenbag wrote:
 
   Hi
   Me again
  
   Still having problems with forms not sending variables, and session
   variables dissapearing.
  
   I have 2 systems, one older 4.0.3 PHP which is my main webserver, so all
   scripts must comply with it...
   And the other my development server with the latest 4.1.2
  
   So, I'm trying to write scripts that will happily work on both, and I
   understand that I must use HTTP_POST_VARS and HTTP_SESSION_VARS in order
   to comply with 4.0.3.
  
   register_globals and track_vars as well as trans_sid are enabled on
   both.
  
   Now, take a look at the example below:
   index.php
  
   form action=page2.php method=POST 
 input type=text name=testinput type=submit name=submit
   /form
  
  
   page2.php
  
   ?php
   session_start();
   echo ' HTTP_POST_VARS :'.$HTTP_POST_VARS[test].'br';
   echo ' POST_VARS: '.$_POST[test].'br';
   echo ' normal test :'.$test.'br';
   echo 'Session Value (only for
   re-entry):'.$HTTP_SESSION_VARS[testing].'br';
  
   if ($HTTP_POST_VARS[test]) {
   $HTTP_SESSION_VARS[testing] = $HTTP_POST_VARS[test];
   }
   echo 'a href=page3.phpClick/a';
   ?
  
   page3.php
  
   ?php
   session_start();
   echo 'Session Variable:'.$HTTP_SESSION_VARS[testing].'br';
   echo 'a href=page4.phpForward to test sess var further/abr';
   echo 'a href=page2.phpBack to test sess var/abr';
   ?
  
   page4.php
  
   ?php
   session_start();
   echo 'Session Variable:'.$HTTP_SESSION_VARS[testing].'br';
   echo 'a href=page3.phpBack to page 3 to test sess var
   further/abr';
   echo 'a href=page2.phpBack to page 2 to test sess var/abr';
   ?
  
   This small test works 100% on my newer system, and I was under the
   impression that I coded it to be backwards compatible with my older
   system, BUT,
  
   look here: http://www.linuxhelp.co.za/session_test to see what it does
   on my working server. The scripts are identical.
  
   Please can you point out my mistakes in reasoning?
  
   Also, I want these scripts to work regardless of cookies, so if you see
   something that might cause problems when ppl disable cookies, plz
   advise.
  
  
  
   --
   PHP General Mailing List (http://www.php.net/)
   To unsubscribe, visit: http://www.php.net/unsub.php
  
 



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




Re: [PHP] $HTTP_SESSION_VARS ? Have I got it wrong

2002-07-17 Thread Martin Clifford

Define the value of $count before registering it, and it should work fine :o)

Martin Clifford
Homepage: http://www.completesource.net
Developer's Forums: http://www.completesource.net/forums/


 Henry [EMAIL PROTECTED] 07/17/02 10:14AM 
The answer is probably yes.

I do a
session_start() followed by a $HTTP_SESSION_VARS['count']=2 on one page.
Then I go to another page and do a session_start() again; unfortunately
the $HTTP_SESSION_VARS['count'] is empty!!!

I tried doing a session_register('count2'); $count2=123; in the first page
followed by another page where I display $count2 and that works fine.

Why?

Henry



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



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




Re: [PHP] $HTTP_SESSION_VARS ? Have I got it wrong

2002-07-17 Thread Martin Clifford

Ignore that, I'll just go grab my copy of Hooked on Phonics so I can learn to read 
before replying.

:trots off:

Martin Clifford
Homepage: http://www.completesource.net
Developer's Forums: http://www.completesource.net/forums/


 Martin Clifford [EMAIL PROTECTED] 07/17/02 10:15AM 
Define the value of $count before registering it, and it should work fine :o)

Martin Clifford
Homepage: http://www.completesource.net 
Developer's Forums: http://www.completesource.net/forums/ 


 Henry [EMAIL PROTECTED] 07/17/02 10:14AM 
The answer is probably yes.

I do a
session_start() followed by a $HTTP_SESSION_VARS['count']=2 on one page.
Then I go to another page and do a session_start() again; unfortunately
the $HTTP_SESSION_VARS['count'] is empty!!!

I tried doing a session_register('count2'); $count2=123; in the first page
followed by another page where I display $count2 and that works fine.

Why?

Henry



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



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



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




Re: [PHP] $HTTP_SESSION_VARS ? Have I got it wrong

2002-07-17 Thread 1LT John W. Holmes

If you're going to use $HTTP_SESSION_VARS, then you have to use
session_register().

?
session_start();
session_register('count');
?

Next page:
?
session_start();
echo $HTTP_SESSION_VARS['count'];
?

That should work. If you use $_SESSION, instead, then you don't have to use
session_register.

That's how I understand it...

---John Holmes...

 Henry [EMAIL PROTECTED] 07/17/02 10:14AM 
The answer is probably yes.

I do a
session_start() followed by a $HTTP_SESSION_VARS['count']=2 on one page.
Then I go to another page and do a session_start() again; unfortunately
the $HTTP_SESSION_VARS['count'] is empty!!!

I tried doing a session_register('count2'); $count2=123; in the first page
followed by another page where I display $count2 and that works fine.

Why?

Henry



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



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



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




Re: [PHP] $HTTP_SESSION_VARS with unset()

2002-03-14 Thread Jim Lucas [php]

I must ask first, why don't you just use the session_destroy() function?

it will kill all related sessions variables and reset the PHPSESSID (if
that's you have it named)

Jim Lucas
www.bend.com

- Original Message -
From: SpamSucks86 [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Thursday, March 14, 2002 4:54 PM
Subject: [PHP] $HTTP_SESSION_VARS with unset()


 when someone logs in, it sets $HTTP_SESSION_VARS with the appropriate
 information. to log them out, I tried just using
 unset($HTTP_SESSION_VARS['valid_user']) but it doesn't actually remove
 it from the session. it will only work if valid_user was set on the same
 script call (for example, if it logs me in and then immediately logs me
 out without making another call to the script). How come
 $HTTP_SESSION_VARS won't destroy session variables unless they're
 created during the same script call? Or maybe it just has to do with if
 $HTTP_SESSION_VARS creates any variable before it deletes any. Thanks
 for your help =)



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




Re: [PHP] HTTP_SESSION_VARS

2001-11-08 Thread Ozgur Demirtas

Regarding the same topic of session management, I am using PHP 3.09 and when
I call session_start() or $HTTP_SESSION_VARS['someVariable]
I get :

Fatal error: Call to unsupported or undefined function session_start()


So, my question is that: Is there any session management in PHP3.09? If the
answer is no, what weould be an alternative?

Regards,
Ozgur

- Original Message -
From: Chris O'Brien [EMAIL PROTECTED]
To: Ron Clark [EMAIL PROTECTED]
Cc: PHP general list [EMAIL PROTECTED]
Sent: Friday, November 09, 2001 3:06 AM
Subject: Re: [PHP] HTTP_SESSION_VARS


  I am working on a major PHP project using sessions and would like to run
  PHP with register_globals turned off. Trouble is, with PHP-4.0.6 I lose
  all the session variables and my program breaks. Tried -
 
 
  $username = $HTTP_SESSION_VARS['username'];
  print $username;
 
  and got nothing.
 
  print_r($HTTP_SESSION_VARS) shows an empty array. Is this a bug in
  4.0.6.

 Try calling session_start(); before trying to grab the session variables,
on
 each page that needs to use the variables.

 * Chris O'Brien ([EMAIL PROTECTED])
 * Excel.Net,Inc. - http://www.excel.net/
 * (920) 452-0455 - Sheboygan/Plymouth area
 * (888) 489-9995 - Other areas, toll-free


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] HTTP_SESSION_VARS

2001-11-08 Thread Johnson, Kirk

 Regarding the same topic of session management, I am using 
 PHP 3.09 and when
 I call session_start() or $HTTP_SESSION_VARS['someVariable]
 I get :
 
 Fatal error: Call to unsupported or undefined function session_start()
 
 
 So, my question is that: Is there any session management in 
 PHP3.09? If the
 answer is no, what weould be an alternative?

Native session management arrived with PHP 4.0. If you are stuck with 3.x,
you might look at PHPLIB, which has a session management class. The best
bet, IMHO, is to upgrade to 4.x, tho.

Kirk

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] HTTP_SESSION_VARS

2001-08-01 Thread Jon Yaggie

SORRY i just coppied it wrong
the actual code is capitalized

while(list($k, $v) = each($HTTP_SESSION_VARS))


- Original Message -
From: Faisal Nasim [EMAIL PROTECTED]
To: Jon Yaggie [EMAIL PROTECTED]
Sent: Thursday, August 02, 2001 12:23 AM
Subject: Re: [PHP] HTTP_SESSION_VARS


 Make session capital!

 $HTTP_SESSION_VARS instead of $HTTP_session_VARS

 Might also use:

 foreach ( $HTTP_SESSION_VARS as $k = $v )
 {
   // etc
 }

 Faisal Nasim
 FreeWebWare.com

 At 12:17 AM 8/2/2001 +0700, you wrote:
 when i try this then   .. . .
 
 
 
 while (list ($key, $val) = each ($HTTP_session_VARS)) {
  echo $key = $valbr;
 }
 
 i get the error -
 
 Warning: Variable passed to each() is not an array or object in
 /var/www/html/adult/func.php on line 5
 
 and well it looks liek an array to me . . is there soemthing i can do to
 make this work?
 
 
 
 Thank You,
 
 Jon Yaggie
 www.design-monster.com
 
 And they were singing . . .
 
 '100 little bugs in the code
 100 bugs in the code
 fix one bug, compile it again
 101 little bugs in the code
 
 101 little bugs in the code . . .'
 
 And it continued until they reached 0


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] HTTP_SESSION_VARS

2001-08-01 Thread Johnson, Kirk

 while (list ($key, $val) = each ($HTTP_session_VARS)) {
 echo $key = $valbr;
 }
 
 i get the error -
 
 Warning: Variable passed to each() is not an array or object 
 in /var/www/html/adult/func.php on line 5

Change HTTP_session_VARS to HTTP_SESSION_VARS, since variable names are
case-sensitive.

Kirk

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] HTTP_SESSION_VARS

2001-08-01 Thread mike cullerton

if there aren't any session vars, $HTTP_SESSION_VARS won't be an array.

i use something like

 if(isset($HTTP_SESSION_VARS)) {
  reset($HTTP_SESSION_VARS);
  while(list($k, $v) = each($HTTP_SESSION_VARS)) {
do_something($k,$v);
  }
 }

on 8/1/01 11:46 AM, Jon Yaggie at [EMAIL PROTECTED] wrote:

 SORRY i just coppied it wrong
 the actual code is capitalized
 
 while(list($k, $v) = each($HTTP_SESSION_VARS))
 


-- mike cullerton   [EMAIL PROTECTED]



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] HTTP_SESSION_VARS

2001-08-01 Thread Richard Lynch

 SORRY i just coppied it wrong
 the actual code is capitalized

 while(list($k, $v) = each($HTTP_SESSION_VARS))

In that case, $HTTP_SESSION_VARS is not an array because you have no session
variables yet...

session_start();
session_register('foo');
$foo = 42;
while (list($k, $v) = each($HTTP_SESSION_VARS)){
echo $k ==gt; $vBR\n;
}

--
WARNING [EMAIL PROTECTED] address is an endangered species -- Use
[EMAIL PROTECTED]
Wanna help me out?  Like Music?  Buy a CD: http://l-i-e.com/artists.htm
Volunteer a little time: http://chatmusic.com/volunteer.htm



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]