session_register depricated
Posted: Wed Apr 11, 2012 11:32 pm
i have been using session_register to pass along the username to the various pages of my data system. i remember it took me forever to figure out how to do that. i like it because as i go from page to page while logged in i can use a query based on the username and do useful things with it
in php 5.3+ i get the 'deprecated' error messages which are annoying. so what i am looking for is a way to register the username variable just like i did with session_register
the login page:
then all the following pages
so i need a way to do what session_register used to do, as easily as it did.
in php 5.3+ i get the 'deprecated' error messages which are annoying. so what i am looking for is a way to register the username variable just like i did with session_register
the login page:
Code: Select all
$username = count($_POST)?$_POST['username']:'';
session_register("username");
$_SESSION['user']=$username;
Code: Select all
session_start();
// to see if the user is logged in
if(!session_is_registered(username)){
header("location:login.php");
}
$usera = $_SESSION["user"];
//echo 'here ' . $usera;