corbin Posted July 2, 2006 Share Posted July 2, 2006 Recently I've started tryin to teach my self about sessions, but i cant figure out how to get sessions to span multiple pages... So far I've been messin around with a very very very simple login script...login.php:[code]<form method=POST action="login_action.php">Name: <input type=text name="name"><BR>Password: <input type="password" name="pass"><BR><input type="Submit" value="submit"></form>[/code]login_action.php:[code]<?include('db.php');$name = $_POST['name'];$pass = $_POST['pass'];$q = "SELECT * from accounts WHERE ((name='$name') && (password='$pass'))";$a = mysql_query($q);$r = mysql_num_rows($a);if($r > 0) {session_start();$SESSION['user'] = $name;}?><a href="test.php">test</a>[/code]and last test.php:[code]<?session_start();echo $SESSION['user'];?>[/code]so lets say i login with the name corbin, on login_action.php it can echo $SESSION['user'] fine, but on test.php it doesnt think SESSION['user'] is set... So pretty much im asking how do i get it to recognize a session from 1 page on another? Quote Link to comment https://forums.phpfreaks.com/topic/13494-new-to-sessions/ Share on other sites More sharing options...
avo Posted July 2, 2006 Share Posted July 2, 2006 HI Take a look here i just posed this one for someone else [url=http://www.phpfreaks.com/forums/index.php/topic,99222.0.html]http://www.phpfreaks.com/forums/index.php/topic,99222.0.html[/url]cheers Quote Link to comment https://forums.phpfreaks.com/topic/13494-new-to-sessions/#findComment-52216 Share on other sites More sharing options...
corbin Posted July 2, 2006 Author Share Posted July 2, 2006 Seems to me that that script doesnt even need to use sessions for what it does...That script doesnt help me (i dont think ???) it just forwards you to different pages based on access level... Im asking how do i get page2.php to echo the session data that was set using page1.php Quote Link to comment https://forums.phpfreaks.com/topic/13494-new-to-sessions/#findComment-52219 Share on other sites More sharing options...
corbin Posted July 2, 2006 Author Share Posted July 2, 2006 Got it. I was using $SESSION and not $_SESSION... Quote Link to comment https://forums.phpfreaks.com/topic/13494-new-to-sessions/#findComment-52232 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.