Jump to content

Problem with session


nati

Recommended Posts

hmm

 

It would be the "Register_Globals" php ini directive, if set to true, any $_REQUEST (and im sure $_SESSION) data gets automatically put into a global variable.

 

Register Globals is quite a common securit flaw for beginners as it seems easier to use it, but for best practice you should try not to rely on global variables (only some safe environment variables).

 

http://uk.php.net/register_globals For more information.

there is also this interesting comment on that page:

 

BEWARE of using register_globals = On, it's not only bad karma but highly dangerous.

 

Consider the following coding:

 

<?php
// assume $_SESSION['user'] = array('Hello', 'World');
// assume session_start() was called somewhere before.

    print('<pre>Contents of array $_SESSION[\'user\']');
    print_r($_SESSION['user']);
    print('<hr>Contents of array $user (PHP SETUP register_globals = On)');
    print_r($user);
    print('</pre>');
?>

 

If you manipulate $user you'll manipulate $_SESSION['user'] as well with PHP SETUP register_globals = On.

 

So please avoid it at any cost, no serious programmer would ever want to have register_globals = On.

Archived

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

×
×
  • Create New...

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.