dmccabe Posted June 5, 2008 Share Posted June 5, 2008 Ok so I have been told that sessions are easy to use and easy to understand, so I am about to prove just how slack I am I decided to set up a little test, so I created 2 php files, one with a form to fill in, that then sets one of the form options to a session variable and then the second one simply says welcome session variable. test1.php <?php session_start(); if (!isset($_POST['ldapname'])) { ?> You must login below with your Windows(Citrix) username and password: <form method="POST" action="<?php echo $PHP_SELF; ?>" name="login"> <table align="center"> <tr> <td>Username:</td> <td><input type="text" name="ldapname"></td> <td><a href=".." title="Click for help on this item"><strong>?</strong></td> </tr> <tr> <td>Password:</td> <td><input type="password" name="ldappass"></td> <td><a href=".." title="Click for help on this item"><strong>?</strong></td> </tr> <tr> <td colspan="2"><input type="submit" value="Login" name="submit"></td> </tr> </table> </form> <?php } else { $_session['ldapname'] = $_POST['ldapname']; header("Location:test2.php"); } ?> test2.php <?php session_start(); echo "Test 2"; echo "<br /> Welcome ".$_session['ldapname']; ?> however there is never anything in $_session['ldapname']; why? Link to comment https://forums.phpfreaks.com/topic/108841-solved-getting-my-head-round-sessions/ Share on other sites More sharing options...
jonsjava Posted June 5, 2008 Share Posted June 5, 2008 Ok so I have been told that sessions are easy to use and easy to understand, so I am about to prove just how slack I am I decided to set up a little test, so I created 2 php files, one with a form to fill in, that then sets one of the form options to a session variable and then the second one simply says welcome session variable. test1.php <?php session_start(); if (!isset($_POST['ldapname'])) { ?> You must login below with your Windows(Citrix) username and password: <form method="POST" action="<?php echo $PHP_SELF; ?>" name="login"> <table align="center"> <tr> <td>Username:</td> <td><input type="text" name="ldapname"></td> <td><a href=".." title="Click for help on this item"><strong>?</strong></td> </tr> <tr> <td>Password:</td> <td><input type="password" name="ldappass"></td> <td><a href=".." title="Click for help on this item"><strong>?</strong></td> </tr> <tr> <td colspan="2"><input type="submit" value="Login" name="submit"></td> </tr> </table> </form> <?php } else { $_session['ldapname'] = $_POST['ldapname']; header("Location:test2.php"); } ?> test2.php <?php session_start(); echo "Test 2"; echo "<br /> Welcome ".$_session['ldapname']; ?> however there is never anything in $_session['ldapname']; why? It's $_SESSION, not $_session Link to comment https://forums.phpfreaks.com/topic/108841-solved-getting-my-head-round-sessions/#findComment-558295 Share on other sites More sharing options...
conker87 Posted June 5, 2008 Share Posted June 5, 2008 however there is never anything in $_session['ldapname']; why? Never mind, just ignore me. Link to comment https://forums.phpfreaks.com/topic/108841-solved-getting-my-head-round-sessions/#findComment-558329 Share on other sites More sharing options...
dmccabe Posted June 6, 2008 Author Share Posted June 6, 2008 It's $_SESSION, not $_session Dear lord, I dont believe it lol :/ Thanks! Link to comment https://forums.phpfreaks.com/topic/108841-solved-getting-my-head-round-sessions/#findComment-558952 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.