Papote
asked on
Alternate for Session_register()
I am using PHP 5.3 and have a code that saves the username using session_register("myuserna me"). I know that it shouldn't be used but when I use session_register("mypasswo rd"); I get an error stating: "Undefined index: myusername".
ASKER
I am actually looking for an alternative to using the session_register(); statement as it is being phased out in newer PHP releases.
ASKER
The original post is incorrect; it is when I use $_SESSION['myusername'] = $myusername; that I get the "Undefined index: myusername" error message.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
hi,
if(!isset($_SESSION['myuse rname'])){
session_register("myuserna me");
}
else
{
$_SESSION['myusername'] = "the value";
}
if(!isset($_SESSION['myuse
session_register("myuserna
}
else
{
$_SESSION['myusername'] = "the value";
}
hi,
for undefined index u can try
if(!isset($_SESSION['myuse rname'])){
$_SESSION("myusername") = "NULL";
}
else
{
$_SESSION['myusername'] = "the value";
}
http://www.phpbuilder.com/board/showthread.php?t=10353837
for undefined index u can try
if(!isset($_SESSION['myuse
$_SESSION("myusername") = "NULL";
}
else
{
$_SESSION['myusername'] = "the value";
}
http://www.phpbuilder.com/board/showthread.php?t=10353837
ASKER
This is part of a login script. I echoed the $_SESSION['myusername'] and $myusername and they both do save the variable, but once I move to another page it isn't defined.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I used session_start(); before echoing and still get undefined index.
make sure the value inside ' ' is the same on all pages. also, is it on a subdomain?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Seems I did leave out session_start(); from the checklogin.php script, every other page did have it.
try to use in such method it might help u
if(!isset($_SESSION['myuse
session_register("myuserna
}