drisate Posted June 8, 2009 Share Posted June 8, 2009 Hey guys ... i have a small session problem. I am creating an admin section that uses an iframe systeme so the only thing that loads in the center part. The probem i have is that the session only works on the index part but not in the center part. Both has the config file included on top where the session is initialized and started. index.php code exemple: <?php include ("config.php"); ?> <html> <head> <title>Admin</title> </head> <body> <table border="0" cellpadding="3" cellspacing="3" width="100%" id="table1"> <tr> <td width="20%"><a href="member.php" target="center">Center</a></td> <td><iframe width="96%" src="member.php" name="centre" id="centre" height="1200" border="0" frameborder="0"></iframe></td> </tr> </table> </body> </html> config.php code exemple: <?php session_start(); // DB $DB_HOST = "localhost"; // Host de la base de donnée $DB_USERNAME = "***"; // Pseudo de la base de donnée $DB_PASSWORD = "***"; // Passe de la base de donnée $DB_NAME = "***"; // Nom de la base de donnée $PHPEcono = mysql_connect("$DB_HOST", "$DB_USERNAME", "$DB_PASSWORD") or die ('Connection à la DB impossible: '.mysql_error()); mysql_select_db($DB_NAME); if ($_POST[connexion] == "Entrer"){ // Start loging check if ($_POST[pseudo]==""){$message = $message." - Votre pseudo est vide.<br>";} if ($_POST[pass]==""){$message = $message." - Votre mot de passe est vide.<br>";} // select $all = mysql_fetch_assoc(mysql_query("SELECT * FROM membre WHERE pseudo='$_POST[pseudo]' and pass='$_POST[pass]'")); if ($all[id]==""){$message = $message." - La combinaison Pseudo/Mot de passe que vous avez entré n'est pas bonne. Si vous avez besoin d'assistance, veuillez SVP communiquer avec nous pendant les heures de bureau et il nous fera plaisir de vous aider.<br>";} if ($message=="" and $all[id]!=""){ // session activation $_SESSION[status] = $all[status]; $_SESSION[pseudo] = $all[pseudo]; $_SESSION[pass] = $all[pass]; $_SESSION[email] = $all[email]; $_SESSION[id] = $all[id]; } } ?> member.php code exemple: <?php include ("config.php"); echo "$_SESSION[status]"; ?> So sessions work in the index but not in the iframe (member.php) they both have the config.php included so wtf? lol Quote Link to comment https://forums.phpfreaks.com/topic/161371-solved-session-prob/ Share on other sites More sharing options...
jxrd Posted June 8, 2009 Share Posted June 8, 2009 You need to put quotes around your array keys as they are strings. Also, arrays aren't expanded in double quotes. You need to encapsulate them within curly brackets, or just not use quotes at all. Quote Link to comment https://forums.phpfreaks.com/topic/161371-solved-session-prob/#findComment-851551 Share on other sites More sharing options...
drisate Posted June 8, 2009 Author Share Posted June 8, 2009 Yeah but thats not whats causing the problem. Quote Link to comment https://forums.phpfreaks.com/topic/161371-solved-session-prob/#findComment-851559 Share on other sites More sharing options...
jxrd Posted June 8, 2009 Share Posted June 8, 2009 Well what is then? Quote Link to comment https://forums.phpfreaks.com/topic/161371-solved-session-prob/#findComment-851560 Share on other sites More sharing options...
drisate Posted June 8, 2009 Author Share Posted June 8, 2009 No idea dude ... i made a echo "<pre>"; print_r($_SESSION); echo "</pre>"; on both ... looks like for some reason the seconde session start is not working. The $_SESSION values are all working fine in the index.php file but are all empty in the member.php one ... Do you think i need to force the SID in the link of the iframe? Quote Link to comment https://forums.phpfreaks.com/topic/161371-solved-session-prob/#findComment-851567 Share on other sites More sharing options...
jxrd Posted June 8, 2009 Share Posted June 8, 2009 What's the value of $_POST['connexion'] ? Quote Link to comment https://forums.phpfreaks.com/topic/161371-solved-session-prob/#findComment-851572 Share on other sites More sharing options...
PFMaBiSmAd Posted June 8, 2009 Share Posted June 8, 2009 Just because you can echo/print_r a variable named $_SESSION on a page where that variable was set, does not mean that sessions are working. Are you developing and debugging your code on a system with error_reporting set to E_ALL and display_errors set to ON in your php.ini so that you would be alerted to problems that php finds (on both pages)? Quote Link to comment https://forums.phpfreaks.com/topic/161371-solved-session-prob/#findComment-851574 Share on other sites More sharing options...
drisate Posted June 8, 2009 Author Share Posted June 8, 2009 Yes those are just code exemples because the whole thing would make to much code for nothing ... but i have a debug line that looks like this in the config.php file if ($debug=="1"){ error_reporting(E_ALL); } and of course $debug is set to 1 Just because you can echo/print_r a variable named $_SESSION on a page where that variable was set Yeah i know i tryed to refresh the page with out sending back the post info and the sessions are remaning so i can asume they are well propageded. + the echo "<pre>"; print_r($_SESSION); echo "</pre>"; returns all the values set Quote Link to comment https://forums.phpfreaks.com/topic/161371-solved-session-prob/#findComment-851584 Share on other sites More sharing options...
PFMaBiSmAd Posted June 8, 2009 Share Posted June 8, 2009 Are you developing and debugging your code on a system with error_reporting set to E_ALL and display_errors set to ON Unless both settings are in a known state, you won't see errors. Edit: And you are setting them before the session_start() so that any errors that occur due to the session_start would be shown? Quote Link to comment https://forums.phpfreaks.com/topic/161371-solved-session-prob/#findComment-851587 Share on other sites More sharing options...
drisate Posted June 8, 2009 Author Share Posted June 8, 2009 Yes i know lol i can see notices in my page but no php errors Go try it your self. I sent you a private message with the link and logging Quote Link to comment https://forums.phpfreaks.com/topic/161371-solved-session-prob/#findComment-851595 Share on other sites More sharing options...
drisate Posted June 8, 2009 Author Share Posted June 8, 2009 I just removed the notice becaus there was alot for nothing lol E_ALL & ~E_NOTICE Once your logged in you should see 2 debug tables. One inside the iframe and one under the iframe. Quote Link to comment https://forums.phpfreaks.com/topic/161371-solved-session-prob/#findComment-851604 Share on other sites More sharing options...
drisate Posted June 8, 2009 Author Share Posted June 8, 2009 nvm ... found my error ... was stupid lol thx anyway ;-) Quote Link to comment https://forums.phpfreaks.com/topic/161371-solved-session-prob/#findComment-851607 Share on other sites More sharing options...
PFMaBiSmAd Posted June 8, 2009 Share Posted June 8, 2009 I only see one debug table and the only iframe in the page has an empty src="" You should fix each Notice error because each line with an error takes at least 10 times longer to execute by php then what the line of code would take if it did not generate the error. Quote Link to comment https://forums.phpfreaks.com/topic/161371-solved-session-prob/#findComment-851608 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.