darkfreaks Posted December 5, 2007 Share Posted December 5, 2007 ok i changed session_register to $_SESSION["variable"] however everytime i click on a new page the session is unset and am logged out even if i dont press logout.php link. thoughts? ??? Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted December 5, 2007 Share Posted December 5, 2007 PHP is case-sensitive. Change it to $_SESSION['variable'] = "value"; Don't forget to call session_start either. Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted December 5, 2007 Author Share Posted December 5, 2007 what would i put for value though? ??? Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted December 5, 2007 Share Posted December 5, 2007 Why are you registering a session if you don't know what you want it to hold? I guess just set it to TRUE. $_SESSION['variable'] = TRUE; Quote Link to comment Share on other sites More sharing options...
teng84 Posted December 5, 2007 Share Posted December 5, 2007 print all the content of your array session use print_r to see if the session is really not set Quote Link to comment Share on other sites More sharing options...
Distant_storm Posted December 5, 2007 Share Posted December 5, 2007 If you are using a session for a login script you should assign it some value for you to check. such as page 1: session_start(); // if the user is authorised and has just logged in create session $_SESSION['auth']= TRUE; $_SESSION['user_id'] = "mememe"; $_SESSION['password_key']="THINGIMIJIG"; header("LOCATION:nextpage.php"); page2: session_start(); #check user is logged in if (isset($_SESSION['auth'])) { //dazel them with your website } Hope that helps Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted December 5, 2007 Author Share Posted December 5, 2007 when i use $_SESSION['variable'] = TRUE; it works but when i click on a link in admin panel it sas my pass and username arent correct? <?php elseif (mysql_num_rows($result) == 0) { unset($_SESSION["aid"]); unset($_SESSION["apass"]);?> Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted December 5, 2007 Share Posted December 5, 2007 when i use $_SESSION['variable'] = TRUE; it works but when i click on a link in admin panel it sas my pass and username arent correct? <?php elseif (mysql_num_rows($result) == 0) { unset($_SESSION["aid"]); unset($_SESSION["apass"]);?> We need more code than that. Quote Link to comment Share on other sites More sharing options...
Distant_storm Posted December 5, 2007 Share Posted December 5, 2007 debug it when it says they arnt correct. Print out session values and what the sessions values are being checked against. Make sure their are no trailing spaces or leading spaces... Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted December 5, 2007 Author Share Posted December 5, 2007 <?php session_start(); include_once "../configuration.inc.php"; require_once "../main.php"; if(!isset($aid)) { ?> <center> <br><p align="right"><font color="#FF6600"><strong><br> Site Admin Area</strong></font> <hr width="100%" size="1" color=#FF6600></p> <table width="278" align="center"> <form method="post" action="<?=$PHP_SELF?>"> <tr> <td>Admin ID:</td> <td> <input type="text" name="aid" size="15"></td> </tr> <tr> <td><?=$PASSWORD1?></td> <td><input type="password" name="apass" size="15"></td> </tr> <tr> <td colspan=2 align=center><input type="submit" value="Login"></td> </tr> <tr><td colspan=2 align=center> <a class=TN href=forgot.php> Forgot your password?</a></td></tr> </form> </table> <?php include "../footer.php"; exit; } $_SESSION["aid"] =TRUE; $_SESSION["apass"] =TRUE; $sql = "SELECT * FROM job_admin_login WHERE aid = '$aid' AND apass = '$apass'"; $result = mysql_query($sql); if (!$result) { echo "A database error occurred while checking your login details. <br>If this error persists, please contact $contactemail"; } elseif (mysql_num_rows($result) == 0) { unset($_SESSION["aid"]); unset($_SESSION["apass"]);?> <h1> <?=$ACCDENIED?> </h1> <p>Your user ID or password is incorrect, or you are not a registered user on this site. To try logging in again, click <a href="<?=$PHP_SELF?>">here</a>. </p> <?php include "../footer.php"; exit; } ?> Quote Link to comment Share on other sites More sharing options...
trq Posted December 5, 2007 Share Posted December 5, 2007 In your query you use two variables, $aid and $apass. These are not defined anywhere in your script. Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted December 5, 2007 Share Posted December 5, 2007 Look $_SESSION["aid"] =TRUE; $_SESSION["apass"] =TRUE; Your not actually giving the sessions the value of the password and whatever "aid" is. How do you expect it to find any results in the DB to match? When they log in you need to give those sessions the correct values. Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted December 5, 2007 Author Share Posted December 5, 2007 fixed Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted December 5, 2007 Share Posted December 5, 2007 so like <?php $_SESSION["aid"] = $aid;?> Well...does the variable $aid have a value? ...and is it the correct value? Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted December 5, 2007 Author Share Posted December 5, 2007 itd written in the .htaccess file but es its just $aid= $_POST["aid"] Quote Link to comment 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.