Link to home
Start Free TrialLog in
Avatar of Papote
PapoteFlag for Puerto Rico

asked on

Alternate for Session_register()

I am using PHP 5.3 and have a code that saves the username using session_register("myusername"). I know that it shouldn't be used but when I use session_register("mypassword"); I get an error stating: "Undefined index: myusername".
Avatar of Insoftservice inso
Insoftservice inso
Flag of India image

hi ,

try to use in such method it might help u

if(!isset($_SESSION['myusername'])){
      session_register("myusername");
      }
Avatar of animesxplosion
animesxplosion

Avatar of Papote

ASKER

I am actually looking for an alternative to using the session_register(); statement as it is being phased out in newer PHP releases.
Avatar of Papote

ASKER

The original post is incorrect; it is when I use $_SESSION['myusername'] = $myusername; that I get the "Undefined index: myusername" error message.
SOLUTION
Avatar of animesxplosion
animesxplosion

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
hi,


if(!isset($_SESSION['myusername'])){
      session_register("myusername");
      }
else
{
$_SESSION['myusername'] = "the value";
}
hi,

for undefined index u can try

if(!isset($_SESSION['myusername'])){
      $_SESSION("myusername") = "NULL";
      }
else
{
$_SESSION['myusername'] = "the value";
}

http://www.phpbuilder.com/board/showthread.php?t=10353837
Avatar of Papote

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
Avatar of hexer4u
hexer4u
Flag of Romania image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Papote

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
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Papote

ASKER

Seems I did leave out session_start(); from the checklogin.php script, every other page did have it.