Jump to content

[SOLVED] Session prob


drisate

Recommended Posts

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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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)?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.