Jay2391 Posted January 2, 2007 Share Posted January 2, 2007 I created a Log in with password and all that good stuffand You can log on to the web site and autheticate.... That is all cool now here is the issue....I can Log in and I carry a variable saying display the name "John Doe"..Then I click and go to another page ... and i can test the session is active ...session(): that is okay ....BUT !!!!!!!!The session does not test to show that the session is "JOHN DOE" session....Example:1.Log in page JOHN DOE AUTHENTICATES2.Confirmation or welcome page... Session is True JOHN DOE YOU ARE LOG IN 3.Page X Session is True "Blank - Nothing displays" you are log in So i can not probe in that page that John Doe is the one log in ????can some one help i have check all the books and I can find a explanation ....I also try passing a variable but i guess i did it wrong. Quote Link to comment https://forums.phpfreaks.com/topic/32572-solved-session-and-id/ Share on other sites More sharing options...
trq Posted January 2, 2007 Share Posted January 2, 2007 Post some related code. Quote Link to comment https://forums.phpfreaks.com/topic/32572-solved-session-and-id/#findComment-151442 Share on other sites More sharing options...
HuggieBear Posted January 2, 2007 Share Posted January 2, 2007 Try posting your code for the login page and the page that's not working, this will give us something to work with.RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/32572-solved-session-and-id/#findComment-151443 Share on other sites More sharing options...
Jay2391 Posted January 2, 2007 Author Share Posted January 2, 2007 okay here is my code...the Authetication page is HTML Name and password you know thw basic stuff...then you get this cheking if you indded logged-in sucessfullyCODE:[code]<?php session_start(); include("LOGINFO.php"); ///////////////Variables/////////////////////////////////////////////////////// $table = 'md_user_main'; $email = $_POST['email']; $password = md5($_POST['password']); $wtd = "relogin";///////////////////////////////database connection and array////////////////// $tc = mysql_connect ($host, $user, $pass); $db = mysql_select_db ($database, $tc); $query = "SELECT * FROM $table WHERE (email=\"$email\") "; $result = mysql_query($query); $row = mysql_fetch_array($result); $fname= $row['first_name']; //////////////////////////Re Log In///////////////////////////////////////////// if($_SESSION['session_var'] == "skipLogin"){ echo "$fname is Log-In"; echo "<br>If you like to end the session, Click here to Log-Off"; }else if($wtd == "relogin"){ if($password == $row['password']){ echo "You are loged In $fname"; $_SESSION['session_var'] = "skipLogin"; }else{ echo "You are not log-In try again"; //session_destroy(); //unset($_SESSION); } }?>[/code]Then I created this test to check if the session and user are log-in in a 3rd page ...here is where the session is active but I can't ID the user.... before i try passing a variable but it didn't work so this is what i have now...what i will like is to say who is Loged In[code]<?php session_start(); if($_SESSION['session_var'] == "skipLogin"){ echo "You are loged-In"; echo "<br>Session still active"; }else{ echo "You stinky"; }?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/32572-solved-session-and-id/#findComment-151465 Share on other sites More sharing options...
trq Posted January 2, 2007 Share Posted January 2, 2007 A simple example.p1.php[code]<?php session_start(); $_SESSION['u'] = "foo"; echo "<a href='p2.php'>click</a>";?>[/code]p2.php[code]<?php session_start(); echo $_SESSION['u'];?>[/code]Does that work? Quote Link to comment https://forums.phpfreaks.com/topic/32572-solved-session-and-id/#findComment-151467 Share on other sites More sharing options...
HuggieBear Posted January 2, 2007 Share Posted January 2, 2007 You need to put the name into a session variable too...[code=php:0]if($password == $row['password']){ echo "You are loged In $fname"; $_SESSION['session_var'] = "skipLogin"; $_SESSION['fname'] = $fname; // I added this line}else{ echo "You are not log-In try again"; //session_destroy(); //unset($_SESSION);}[/code] Then when you echo [code=php:0]$_SESSION['fname'][/code] you get their name.RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/32572-solved-session-and-id/#findComment-151468 Share on other sites More sharing options...
Jay2391 Posted January 2, 2007 Author Share Posted January 2, 2007 Good Stuff !!!! Yeah I was doing my passing variable wrong ;D Quote Link to comment https://forums.phpfreaks.com/topic/32572-solved-session-and-id/#findComment-151472 Share on other sites More sharing options...
Jay2391 Posted January 2, 2007 Author Share Posted January 2, 2007 one more ?I put this on my session test ... but it won't show the name, if I put the $_SESSION['fname'] in a variableif i do """" echo $_SESSION['fname']; """"" that display the name but when i do a variable like below it just show """"" You are loged In """""<?php session_start(); if($_SESSION['session_var'] == "skipLogin"){ $_SESSION['fname'] = $fname; echo "You are loged In $fname"; }else{ echo "You stinky"; }?> Quote Link to comment https://forums.phpfreaks.com/topic/32572-solved-session-and-id/#findComment-151572 Share on other sites More sharing options...
Jay2391 Posted January 2, 2007 Author Share Posted January 2, 2007 can you check my preavious post ...one small issue with the variable and session Quote Link to comment https://forums.phpfreaks.com/topic/32572-solved-session-and-id/#findComment-151594 Share on other sites More sharing options...
KevinM1 Posted January 2, 2007 Share Posted January 2, 2007 [quote author=Jay2391 link=topic=120690.msg495465#msg495465 date=1167761750]one more ?I put this on my session test ... but it won't show the name, if I put the $_SESSION['fname'] in a variableif i do """" echo $_SESSION['fname']; """"" that display the name but when i do a variable like below it just show """"" You are loged In """""<?php session_start(); if($_SESSION['session_var'] == "skipLogin"){ $_SESSION['fname'] = $fname; echo "You are loged In $fname"; }else{ echo "You stinky"; }?>[/quote]You have to remember how variable assignment works. The left side of the statement is assigned the value of the right side. So, if you haven't defined $fname in your script, you're merely overwriting your session variable with an empty local variable, hence no output. Since it looks like you're trying to assign a local variable the contents of your session variable, switch the statement around. In other words:$fname = $_SESSION['fname']; Quote Link to comment https://forums.phpfreaks.com/topic/32572-solved-session-and-id/#findComment-151600 Share on other sites More sharing options...
Jay2391 Posted January 2, 2007 Author Share Posted January 2, 2007 I tough i had try that and it didn't work ... but it seems to work now ....anyways thanks and sorry for the bugging with this...makes me mad i tought i try that maybe next time i should close my browser Quote Link to comment https://forums.phpfreaks.com/topic/32572-solved-session-and-id/#findComment-151602 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.