user4fun Posted March 28, 2009 Share Posted March 28, 2009 everytime I raed an article about sessions, I read it line by lne until I understanded as then at the end it says, this is no longer valid, do not use???session_register is deprecated$_SESSION['yadayada'] = "something I am storing"; is also no longer functional!!!!!!What is it that does work, How can I start a session and store the $myusername and $mypassword variables?? Link to comment Share on other sites More sharing options...
zppblood Posted March 28, 2009 Share Posted March 28, 2009 Make sure you have session_start() at the top. Set a value for the session $_SESSION['var']='somevalue'; then if you want to put that in a variable, just do it like you would normally.$somevar=$_SESSION['var']; Link to comment Share on other sites More sharing options...
user4fun Posted March 28, 2009 Author Share Posted March 28, 2009 page1.php some stuffif($count==1){session_start();$_SESSION['accountname'] = '$myusername';header("location:page2.php");}else{echo "Wrong Username or Password";} page2.php <? $myusername= $_SESSION['accountname'];echo "Hello ". $myusername; ?> The output is onlyHelloWhat am i doing wrong? Link to comment Share on other sites More sharing options...
Ingolme Posted March 28, 2009 Share Posted March 28, 2009 You have to have session_start() on every page where you'll be using session variables. Link to comment Share on other sites More sharing options...
user4fun Posted March 28, 2009 Author Share Posted March 28, 2009 oopsThank you Link to comment Share on other sites More sharing options...
jeffman Posted March 28, 2009 Share Posted March 28, 2009 The session_register() function is deprecated. Most other sessions functionality works fine. Most applications only ever need the session_start() function and the $_SESSION array. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.