Jump to content

Archived

This topic is now archived and is closed to further replies.

Janus13

PHP Variables sticking

Recommended Posts

I've been trying to trace down a strange problem on some of my php pages where the page wouldn't carry variables from a sql query. The variables would end up being the logged on user's variables. My question, is once you set a variable in a page, does it clear when you leave that page or do you have to unset it?

Also, if I set a session variable of username, and then define a variable of $username, would those conflict?

Share this post


Link to post
Share on other sites
It sounds like you might have register_globals switched on in your php.ini file. It should be switched off, at least for security reasons.

Share this post


Link to post
Share on other sites
[!--quoteo(post=351766:date=Mar 5 2006, 06:34 AM:name=Janus13)--][div class=\'quotetop\']QUOTE(Janus13 @ Mar 5 2006, 06:34 AM) [snapback]351766[/snapback][/div][div class=\'quotemain\'][!--quotec--]
I've been trying to trace down a strange problem on some of my php pages where the page wouldn't carry variables from a sql query. The variables would end up being the logged on user's variables. My question, is once you set a variable in a page, does it clear when you leave that page or do you have to unset it?
[/quote]
Variables are only available on the page your set them on. If you want your variables to be available to you on the next page then you'll want to use sessions or transfer the data via the URL, but only if its not personal info being passed over the url. If it is then use sessions.

[!--quoteo(post=351766:date=Mar 5 2006, 06:34 AM:name=Janus13)--][div class=\'quotetop\']QUOTE(Janus13 @ Mar 5 2006, 06:34 AM) [snapback]351766[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Also, if I set a session variable of username, and then define a variable of $username, would those conflict?
[/quote]
From what you mentioned here I feel that you register_gloabls set to on which can be a big no no! As this can bring security issues to your site. When you srt register)globals to off you shouldn't get variable conflicts, as you use super global arrays to retrieve your session, post, get data use $_SESSION, $_POST or $_GET and many others.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.