Question on register_globals in PHP
Does this setting needs to be on or off in PHP.ini? I heard that there are a lot of security issues if register_globals is on but then I need to use variables across multiple PHP files for a session. How do I achieve this without having register_globals on?
I read the PHP manual but the $_SESSION doesn't appear to work across multiple files. Any clues or ideas as to how to overcome this problem? |
You have to put :
session_start() at the top of each php scripts that use session, so $_SESSION become available. Make sure you correctly set your session variables too... PHP Code:
PHP Code:
|
Well, I used session_start () on the top of the page:
Listing of firstpage.php PHP Code:
PHP Code:
The PHP manual says that session_register () functions are deprecated or outdated and I'm asked to use only $_SESSION for accessing session state variables. How do I get around this problem? |
I don't see the code where you assign value in $_SESSION['username'], try to change the
second script to something like : PHP Code:
PHP Code:
After went to www.php.net, I decided to not use session_register no more ;) |
Hey thanks. $_POST works fine. Never thought of that though. So to use form fields, I use the $_POST superglobal and then assign it to a session variable.
Don't know how I missed that... |
All times are GMT -5. The time now is 03:52 PM. |