Hi Well, what i can think of (and its happened to me) is session timeouts, how long does your session last?
Just a note, in newer php versions, session_register is not required, all you need is session_start, and then use $_SESSION['variablename'] to set the variable. session register used to be there to set the variable as a global, so instead of using $HTTP_SESSION_VARS['xebitsession'] you could use $xebitsession i noticed something else too, (maybe its how you want it) but in first section you have if (isset($_SESSION[$xebitsession])), unless $xebitsession is set somewhere, that code should be if (isset($_SESSION['xebitsession'])) same with everywhere else, unless $xebitsession is set, anwhere that there is $_SESSION[$xebitsession] should become $_SESSION['xebitsession'] Maybe you could try it with a cookie instead and see if the same thing happens? HTH Luke "Tony Crockford" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I hope someone can help. > > I have a simple login process that someone wrote for me. > > It uses two stored variables which it checks on each new page, if it can't > get them it assumes you should login first and sends you to a login page. > > Everything was okay. > > I used the same script on a different server (with almost identical PHP > setup) and now I'm getting randomly logged out. (it works fine locally and > remotely on a different server) > > Can some-one suggest some useful things I could check to try and track > down the problem? > > Many thanks > > Tony > > This is the check that gets called from each page: > > <? > session_start(); > > //check to see if the session is set. (the session is set when the user > logs in) > //if the session is set, then it must have some data in it... in this case > we have the user_ref and the group_ref, so that we can see who is logged > in and what group they belong to. > //if the session isnt set, then we redirect the user to the login.php page > so that they can log in or if they cant log in they get an error message. > > if (isset($_SESSION[$xebitsession])) { > > $user_ref=$_SESSION[$xebitsession]['user']["user_ref"]; > $group_ref=$_SESSION[$xebitsession]['user']["group_ref"]; > > } else { > > header("location:logged.php"); > } > ?> > > this is the login: > <?php > include("db.php"); > > mysql_connect($db_Hostname, $db_UserName, $db_Password); > mysql_select_db($db_Database); > > session_start(); > session_register("xebitsession"); > > function displaylogin() { > > include("includes/header.html"); > // open content body table > include("includes/contentheader.html"); > include("includes/title.html"); > include("includes/contentheader2.html"); > include("includes/contextheader.html"); > include("includes/contentbody.html"); > > ?> > > <h3>User Login</h3> > > <table width="100%" cellpadding="5" cellspacing="2" border="0"> > <tr> > <td width="20%"></td> > <td><img src="img/t.gif" width="410" height="1" border="0"></td> > </tr> > > <tr> > <td class="menu">Login</td> > <td class="content">Please enter your username and password below.</td> > </tr> > > <tr> > <td class="menu">Username:</td> > <td class="content"> > <?php > echo '<form method="post" action="' . $_SERVER['PHP_SELF'] . '">' . "\n"; > echo '<input type="text" name="user" value="' . $_POST['user'] . > '"></td>' . "\n"; > ?> > </tr> > > <tr> > <td class="menu">Password:</td> > <td class="content"><input type="password" name="pass"></td> > </tr> > > <tr> > <td class="menu"> </td> > <td class="content"><? echo $state;?> > </td> > </tr> > > <tr> > <td class="button"> </td> > <td class="button"><input type="submit" value="Login"> > </form> > </td> > </tr> > </table> > > <?php > > //close content table section > include("includes/contentfooter.html"); > //close page section > include("includes/footer.html"); > > } > $username=$_POST[user]; > $pass=$_POST[pass]; > $username = addslashes($username); > > if (!$username) { > displaylogin(); > } else { > > $sql="SELECT * FROM duser WHERE upass='$pass' AND username='$username'"; > $result = mysql_query($sql); > > // Start the login session > if (! isset ($_SESSION[$xebitsession])) { > while ( $row = mysql_fetch_array($result) ) > { > $_SESSION[$xebitsession]['user']["user_ref"] =$row['user_ref']; > $_SESSION[$xebitsession]['user']["group_ref"]=$row['group_ref']; > } > header("location:index.php"); > } > else { > header("location:index.php"); > } > > } > ?> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php