cooldude832 Posted August 3, 2007 Share Posted August 3, 2007 I am trying to make a login without mysql and it looks like <?php session_start(); $username = "Admin"; $password = "user"; if($_POST['login'] == "yes"){ $user = $_POST['username']; $pass = $_POST['password']; if($user == $username && $pass == $password){ $_SESSSION['admin'] = "yes"; header("location: admin.php"); echo "<pre> Login Valid</pre>"; } else{ echo "<pre>Invalid Login Information</pre><br/>"; die(include("login.html")); } } if($_SESSION["admin"] != "yes"){ echo "Session: ".$_SESSION["admin"]."<br/>"; die(include("login.html")); } else{ echo "logged in"; } ?> It test the username perfectly except it doesn't display the session right after logging in as it should it just says Session: and the login part I have tried Double/single quotes on the session no difference, kinda getting annoying Quote Link to comment https://forums.phpfreaks.com/topic/63137-solved-sessions-not-registering-as-should/ Share on other sites More sharing options...
seikan Posted August 3, 2007 Share Posted August 3, 2007 You test this on local ? Make sure you enable your session support and the "session.save_path" is existed. (Check from your phpinfo()) Quote Link to comment https://forums.phpfreaks.com/topic/63137-solved-sessions-not-registering-as-should/#findComment-314625 Share on other sites More sharing options...
teng84 Posted August 3, 2007 Share Posted August 3, 2007 heres where you initialize your session right? if($user == $username && $pass == $password){ $_SESSSION['admin'] = "yes"; header("location: admin.php"); echo "<pre> Login Valid</pre>"; } now i believe that condition is not satisfied so no initialization took place why? if that is correct the you should get the error saying header cannot send somtething because you echo something under the header Quote Link to comment https://forums.phpfreaks.com/topic/63137-solved-sessions-not-registering-as-should/#findComment-314627 Share on other sites More sharing options...
cooldude832 Posted August 3, 2007 Author Share Posted August 3, 2007 try it out http://pira00.worldispnetwork.com/kaco/admin.php and the php info http://pira00.worldispnetwork.com/kaco/info.php not making much sense Quote Link to comment https://forums.phpfreaks.com/topic/63137-solved-sessions-not-registering-as-should/#findComment-314629 Share on other sites More sharing options...
teng84 Posted August 3, 2007 Share Posted August 3, 2007 weird i think it actually worrk but because the header thing it doesnt show the message try to remove the header file or comment it first in this code if($user == $username && $pass == $password){ $_SESSSION['admin'] = "yes"; header("location: admin.php");-<<<<<<<<<<comment this first echo " Quote Link to comment https://forums.phpfreaks.com/topic/63137-solved-sessions-not-registering-as-should/#findComment-314633 Share on other sites More sharing options...
seikan Posted August 3, 2007 Share Posted August 3, 2007 Can you try out: session_start(); $_SESSION['user'] = "abcde"; echo "User: ->". $_SESSION['user']."<-"; If nothing displayed, there must be something wrong with the session path. Quote Link to comment https://forums.phpfreaks.com/topic/63137-solved-sessions-not-registering-as-should/#findComment-314634 Share on other sites More sharing options...
cooldude832 Posted August 3, 2007 Author Share Posted August 3, 2007 yeah, teng84 no good <?php session_start(); $username = "Admin"; $password = "user"; if($_POST['login'] == "yes"){ $user = $_POST['username']; $pass = $_POST['password']; if($user == $username && $pass == $password){ $_SESSSION['admin'] = "yes"; //header("location: admin.php"); echo "<pre>match</pre>"; } else{ echo "<pre>Invalid Login Information</pre><br/>"; die(include("login.html")); } } if($_SESSION['admin'] != "yes"){ echo "Session: ".$_SESSION['admin']."<br/>"; die(include("login.html")); } else{ echo "logged in"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/63137-solved-sessions-not-registering-as-should/#findComment-314635 Share on other sites More sharing options...
cooldude832 Posted August 3, 2007 Author Share Posted August 3, 2007 I feel like an idiot, but we all should I had $_SE(SSS)ION instead of $_SE(SS)ION Quote Link to comment https://forums.phpfreaks.com/topic/63137-solved-sessions-not-registering-as-should/#findComment-314637 Share on other sites More sharing options...
teng84 Posted August 3, 2007 Share Posted August 3, 2007 damn for the both of us lol Quote Link to comment https://forums.phpfreaks.com/topic/63137-solved-sessions-not-registering-as-should/#findComment-314638 Share on other sites More sharing options...
seikan Posted August 3, 2007 Share Posted August 3, 2007 Oh, just reliazed that spelling mistake. You should use a syntax highlighted editor to avoid this. Haha, have a nice day~ Quote Link to comment https://forums.phpfreaks.com/topic/63137-solved-sessions-not-registering-as-should/#findComment-314639 Share on other sites More sharing options...
cooldude832 Posted August 3, 2007 Author Share Posted August 3, 2007 technically its not an error (unless you are using strict) because you could have a superglobal array called SESSSION (three Ss) which all ti was doing was registering a static value instead of the session value. I would need an editior that would pick up on predefined superglobals, which notepad++ doesnot Quote Link to comment https://forums.phpfreaks.com/topic/63137-solved-sessions-not-registering-as-should/#findComment-314642 Share on other sites More sharing options...
teng84 Posted August 3, 2007 Share Posted August 3, 2007 i use dreamweaver and its good for me Quote Link to comment https://forums.phpfreaks.com/topic/63137-solved-sessions-not-registering-as-should/#findComment-314652 Share on other sites More sharing options...
cooldude832 Posted August 3, 2007 Author Share Posted August 3, 2007 dreamweaver is not a text editor which is what you really need to build code in. Dreamweaver is for the novice person who can't build layouts by hand so they use the GUI's in dreamweaver to build code. You can find text editors with ftps built into them for your needs if that is what you use it. Quote Link to comment https://forums.phpfreaks.com/topic/63137-solved-sessions-not-registering-as-should/#findComment-314654 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.