Session problem !

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mortadelle
Forum Newbie
Posts: 7
Joined: Fri Nov 22, 2002 9:31 am
Contact:

Session problem !

Post by mortadelle »

My session based authentification system works fine on my dev server (NT4 , apache, php 4.2.3) and fails on my web host ( NT5 , website, php 4.2.3 ) i dont know why ....

first page :

Code: Select all

login.php  : 
session_start();
if (isset($_SESSION) && sizeof($_SESSION)>0) 
{
    session_unset(); // session_destroy
}


function Identify($login,$mdp)
{
 global $sess_id, $link, $PHPSESSID, $_SESSION, $HTTP_SESSION_VARS;
//... DATABASE request ... it's matching then :
    $sess_id=$var->id;
    session_register("sess_id");    
/*
note :
i've ttried this too : 
   $HTTP_SESSION_VARSї"sess_id"]=$sess_id;
or $_SESSIONї"sess_id"]=$sess_id;
*/

  header("Location: index.php?PHPSESSID=".$PHPSESSID);
  exit();
}

// When the form is posted :

if (isset($login) && Trim($login)!="" && isset($mdp) && Trim($mdp)!="")
{
  Identify($login, $mdp);
}
and finally of course the HTML form with method = POST and action = login.php ang html input login & mdp...


Second page :

Code: Select all

index.php 

session_start();

if (!isset($_SESSIONї'sess_id']))
{
    header("location: login.php");
}

include "page1.php";
include "page2.php";
....
In my index.php are included all the files i display...
So each time i made a form or url link, i pass the PHPSESSID value and the session is recognized and go on working.

But sometimes it dont ! Exemple, if i do some refresh on a page that has been recognized, it work and in a while (never the same time ) it fails.

I dont know why ?? it's like the session was destroyed in index.php sometimes and sometimes not ?

Anyone could explain me why ?? or is it my structure that is bad ? Moreover as this always work on my local server i though it was fine .....

Thx for help because i'm stuck on this for a long time ....
serg4444
Forum Newbie
Posts: 9
Joined: Fri Nov 22, 2002 10:27 am

Post by serg4444 »

You can use HTTP_GET_VARS for see each values you receive at your page

Sincerely,
Sergey Booyny
AlarIT programmer
http://www.AlarIT.com
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Check the php.ini of each PHP installation, it is likely that register_globals is on in one and off in the other:
viewtopic.php?t=511

Mac
mortadelle
Forum Newbie
Posts: 7
Joined: Fri Nov 22, 2002 9:31 am
Contact:

Post by mortadelle »

nop register_globals is ON on each php.ini server config. moreover all vars. ni php.ini are identical ...
Post Reply