Ok,
I found that when I'm logged and I hit F5 to refresh the page I lost my session

.
ok here is my code ('/lib/session.php') that I include on every page.
Code: Select all
<?
session_start();
include($_SERVER['DOCUMENT_ROOT'].'/lib/objects/session.php');
$ERROR_UNSERIALIZE = 3;
if ( isset( $_SESSION['session'] ) ){
$objSession = unserialize( $_SESSION['session'] );
if ( empty($objSession) ){
unset( $_SESSION['session'] );
$_SESSION['error'] = $ERROR_UNSERIALIZE;
header("Location: /");
exit;
}
$lan = strtolower( $objSession->Member->langue );
}else{
if( isset( $_SESSION['langue'] ) ){
if ( isset($GP_l) ){
$_SESSION['langue'] = $GP_l;
}
}else{
$_SESSION['langue'] = 'en';
}
$lan = $_SESSION['langue'];
$objSession =& new Session();
}
?>
login.php
Code: Select all
<?php
// ACCESS //
include ($_SERVER['DOCUMENT_ROOT'].'/lib/session.php');
# constante d'erreur de login
$ERROR_LOGIN = 1;
if ( $objSession->Member->login( $GP_txtUsager, $GP_txtPassword )){
try{
$query_config_membre = "call Config_Membre_Get(".$objSession->Member->num_membre.");";
$objSession->MySQL->executeSP( $query_config_membre );
# conserve les données obtenu.
$Config = $objSession->MySQL->store_result()->fetch_object();
$objSession->MySQL->free_result();
}catch ( UTException $e ){
echo $e->getError();
exit;
}catch ( Exception $e ){
echo $e->getCode()."<br>".$e->getMessage()."<br>".$e->getTraceAsString();
exit;
}
}else{
unset( $_SESSION['session'] );
$_SESSION['error'] = $ERROR_LOGIN;
header("Location: /");
exit;
}
$objSession->sess_quete_num = 1;
$_SESSION['session'] = serialize( $objSession );
#session_write_close();
if( $Config->num_defaut_personnage ){
header("Location: /quest/character/overview/");
}else{
header("Location: /quest/member/character/");
}
?>
I tried session_write_close(), but no cigar.
Here is the behavior: On my home.php I log me in, the form post redirect me to the login.php, the code above create the session and redirect me with header location to another page like securedpage.php, I print_r() the object and all my information is correct. I Hit refresh and the print_r() show me an empty object. My session is lost and I have to re-login.
Note that the $_SESSION['session'] content an object. I use serialize, and unserialize.
I lost some many hours on that stupid bug

, I noted that this bug appears when I added an instance of Member Object in my session object.
here is a print_r() of my object.
Code: Select all
Session Object
(
# mySQL Object is a singleton.
[_MySQL] => mySQL Object
(
)
[_Member] => Member Object
(
[_MySQL] => mySQL Object
(
)
[_num_membre] => 42
[_usager] => o
[_langue] => en
[_points_remaining] => 1000
[_bg_color] => _gray
[_top_menu] => 1
[_left_menu] => 0
[_tool_tip] => 1
[_resolution] => 780
[_nom] =>
[_prenom] =>
[_nomclan] =>
[_adresseweb] =>
[_pays] =>
[_email] =>
[_email_cell] =>
[_age] => 0000-00-00
[_sexe] =>
[_photo] =>
[_icq] => 0
[_clan] =>
[_date] => 0000-00-00 00:00:00
[_id_unique] =>
[_accepte] =>
[_adressewebclan] =>
[_locked] =>
[_parain] => 0
[_warning] => 0
)
[_sess_db_name] => UnwrittenTales
[_sess_error] => 0
[_sess_perso_num] => 0
[_sess_perso_nom] =>
[_sess_perso_statut] => 0
[_sess_quete_num] => 1
[_sess_quete_jour] => 0
[_sess_quete_annee] => 0
)
I use Firefox 2.0.0.5 and IE 7.0.5730.11
I use local WAMP5 Version 1.7.1
Created by Romain Bourdon (
romain@anaska.com)
Powered by Anaska
http://www.anaska.com
Sources are available at SourceForge
http://www.wampserver.com
to host apache and mysql on my windows XP Pro. After I check-in my code on my linux box with eclipse and cvs.
Thanks for your time

.