...

View Full Version : trouble with Register_Global function with the newest PHP versions



dva
01-05-2006, 03:04 PM
Hello,
I`m new around here and having a problem with the new hosting companies that have installed the newest versions of the PHP.
the register_global settings it`s turrned off ( disabled ) as default and my web script it`s based on register_global enabled

The session start script shows like this :


session_start();
if(isset($_POST['set']) && $_POST['set']=="login"){
header("Cache-control: private");
session_register("mail");
session_register("pase");
$mail=$_POST['mail'];
$pase=$_POST['pass'];
}elseif(isset($_GET['logout']) && $_GET['logout']=="user"){
session_unregister("mail");
session_unregister("pase");
session_destroy();


How can I modify it so I can make it work with register_global disabled ? Or at least another option...

firepages
01-05-2006, 04:58 PM
register_globals=on
session_register("name");
$name='blah';
register_globals=off
$_SESSION['name'] = 'blah';

to get the values echo $_SESSION['name']; etc

PS this is the SNIPPETS forum , moving you to regular PHP

Rich Pedley
01-05-2006, 07:43 PM
and if I am correct:

$_SESSION['name'] = 'blah';

can be used in either case and is therefore the best one to use.

firepages
01-06-2006, 02:51 AM
sorry yes, if PHP > = 4.1 (or is it 4.0.1?) then you should use $_SESSION regardless of register_globals if you want your scripts more secure.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum