turbo Posted March 17, 2007 Share Posted March 17, 2007 With PHP 5 the default setting for register globals is off. This means that sessions variables don't work (see quote below). So, I have a website that makes plenty of use of sessions, which has stopped working properly. The question is, what changes do i have to make to ensure I can still make use of them or something similar to them? Thanks "If you want your script to work regardless of register_globals, you need to instead use the $_SESSION array as $_SESSION entries are automatically registered. If your script uses session_register(), it will not work in environments where the PHP directive register_globals is disabled." Link to comment https://forums.phpfreaks.com/topic/43154-sessions-dont-work/ Share on other sites More sharing options...
kenrbnsn Posted March 17, 2007 Share Posted March 17, 2007 Sessions work fine. What you don't want to use is the "session_register()" function. You explicitly set the session variables using <?php session_start(); $_SESSION['somevar'] = $some_var; $_SESSION['anothervalue'] = 'This will be stored'; ?> and you get the stored values explicitly also: <?php session_start(); echo '$somevar in the Session is: ' . $_SESSION['somevar']; ?> Ken Link to comment https://forums.phpfreaks.com/topic/43154-sessions-dont-work/#findComment-209554 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.