For Programmers: Free Programming Magazines  


Home > Archive > PHP Language > April 2007 > trying to access variable on different pages with reigster_globals = Off









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author trying to access variable on different pages with reigster_globals = Off
Paul

2007-04-06, 3:59 am

I am taking over an exisitng app. I have the following function on page1:
function check($v) {
global $user;
return $user->validate($v[1], $v[0]);
}
It is in this validate function of that class (which is referenced from
another file) that the $user object is set. $user is referenced on page2
like:

session_register('user');
$user=$_SESSION['user'];

since the ini setting register_globals is Off so the above code fails -
$user is empty.

Any ideas to how to make sure $user is accessible on the second page?


Steve

2007-04-06, 3:59 am


"Paul" <lof@invalid.com> wrote in message news:2sbRh.25668$B7.8237@bigfe9...
|I am taking over an exisitng app. I have the following function on page1:
| function check($v) {
| global $user;
| return $user->validate($v[1], $v[0]);
| }
| It is in this validate function of that class (which is referenced from
| another file) that the $user object is set. $user is referenced on page2
| like:
|
| session_register('user');
| $user=$_SESSION['user'];
|
| since the ini setting register_globals is Off so the above code fails -
| $user is empty.
|
| Any ideas to how to make sure $user is accessible on the second page?

paul,

search for this post by phil buchman:

'Re: Need a simple database for name and email only'

i posted several scripts that work together to provide the basics for site
configuration, user verification, automated emails...and of course, the
relative path thing. ;^)

from all of that, you should see your question answered.

btw, AT ALL COSTS, DO NOT USE global $variable conventions in functions!!!
functions get fed PARAMETERS...all else is MAGIC one has to guess at in a
less than structured environment where more often than not, your eye will
not surpass the hand in speed.


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com