dreamwest Posted September 21, 2009 Share Posted September 21, 2009 I cant seem to set this session for some reason: <?php session_start(); $comfirm = $_POST['confirm']; if($confirm != ""){ $_SESSION['confirm'] = 1; } if($_SESSION['confirm']){ $session = "ok"; echo "im set!!"; } ?> <form action="" method="POST"> <input type="hidden" name="confirm" value="yes" > <input style="margin-right: 5px; " type="submit" value="Confirm User"> </form> Link to comment https://forums.phpfreaks.com/topic/174964-_session-cant-set/ Share on other sites More sharing options...
phpdeveloper82 Posted September 21, 2009 Share Posted September 21, 2009 Try the following: <?php session_start(); if($_POST) { $comfirm = $_POST['confirm']; if($comfirm) { $_SESSION['confirm'] = 1; } if($_SESSION['confirm']) { $session = "ok"; echo "im set!!"; } } ?> <form action="" method="POST"> <input type="hidden" name="confirm" value="yes" > <input style="margin-right: 5px; " type="submit" value="Confirm User"> </form> Link to comment https://forums.phpfreaks.com/topic/174964-_session-cant-set/#findComment-922123 Share on other sites More sharing options...
ozestretch Posted September 21, 2009 Share Posted September 21, 2009 Is that counted as whitespace? Link to comment https://forums.phpfreaks.com/topic/174964-_session-cant-set/#findComment-922126 Share on other sites More sharing options...
dreamwest Posted September 21, 2009 Author Share Posted September 21, 2009 For some reason the $confirm variable was interfering, dont know why but it now works: <?php session_start(); $yes = $_POST['confirm']; if($yes != ""){ $_SESSION['confirm'] = 1; } if($_SESSION['confirm']){ $session = "ok"; echo "im set!!"; } ?> <form action="" method="POST"> <input type="hidden" name="confirm" value="yes" > <input style="margin-right: 5px; " type="submit" value="Confirm User"> </form> Link to comment https://forums.phpfreaks.com/topic/174964-_session-cant-set/#findComment-922190 Share on other sites More sharing options...
gevans Posted September 21, 2009 Share Posted September 21, 2009 typo; $comfirm = $_POST['confirm']; You set the variable as 'comfirm' then checked the varialbe 'confirm' Link to comment https://forums.phpfreaks.com/topic/174964-_session-cant-set/#findComment-922191 Share on other sites More sharing options...
ozestretch Posted September 21, 2009 Share Posted September 21, 2009 Don't you just hate them typos nice catch Link to comment https://forums.phpfreaks.com/topic/174964-_session-cant-set/#findComment-922203 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.