Jump to content

session times out and reborn after refresh!!!


dourvas

Recommended Posts

hallo there,

 

i ve coded a login system using sessions (php - mysql). It was working fine for 2-3 months. Lately some errors are occuring. i can not understand why.

 

when the user tries to login through a login form a query is executing searching into the database for both username and password. if the data are there i just put into sessions-variables some database data.

i am giving the php file which executes the button login on the login form

<?php session_start();

$errmsg_arr = array();

$errflag = false;

include '../config_db.php';

//Function to sanitize values received from the form. Prevents SQL injection
function clean($str) {
	$str = @trim($str);

	if(get_magic_quotes_gpc()) {
		$str = stripslashes($str);
	}
	return mysql_real_escape_string($str);
}

//Sanitize the POST values
$login = clean($_POST['login']);
$password = clean($_POST['password']);

//Input Validations
if($login == '') {
	$errmsg_arr[] = 'Login ID missing';
	$errflag = true;
}
if($password == '') {
	$errmsg_arr[] = 'Password missing';
	$errflag = true;
}

//If there are input validations, redirect back to the login form
if($errflag) {
	$_SESSION['ERRMSG_ARR'] = $errmsg_arr;
	session_write_close();
	header("location: login/login-form.php");
	exit();
}
	//Create query
$qry="SELECT * FROM members WHERE login='$login' AND passwd='$password'";
$result=mysql_query($qry);

if($result) {
	if(mysql_num_rows($result) == 1) {
		//Login Successful
		session_regenerate_id();
		$member = mysql_fetch_assoc($result);
		$_SESSION['login']= "ok";
		$_SESSION['SESS_MEMBER_ID'] = $member['member_id'];
		$_SESSION['SESS_FIRST_NAME'] = $member['firstname'];
		$_SESSION['SESS_LAST_NAME'] = $member['lastname'];
		$_SESSION['SESS_CLASS'] = $member['class'];
            	   	$_SESSION['SESS_FATHERSNAME'] = $member['fathersname'];

		session_write_close();

		header("location: ../index.php");
		exit();
	}else {
		//Login failed
		header("location: login-failed.php");
		exit();
	}
}else {
	die("Query failed");
}
?>

every page on the site begins with starting a session and then checking if the visitor is logged in. If the visitor is logged in some different data appears in every session along with the message "welcome".

i am giving u the starting code of a typical page of my site

<?php session_start();
//error_reporting(E_ALL ^ E_NOTICE);
if ($_SESSION['login'] == "ok")
   {
    $logggedin = true;
    }
else
   {
     $logggedin = false;
   }
   include 'config_paths.php';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html
xmlns="http://www.w3.org/1999/xhtml"
lang="en"
xml:lang="en"
><head>

<meta
http-equiv="Content-Type"
content="text/html; charset=windows-1253"
/>

<!-- EDW EINAI TO CSS ARXEIO POY PERIEXEI OLES TIS MORFOPOIHSEIS -->
<link
type="text/css"
rel="stylesheet"
href="screen.css"
media="screen,projection,tv"
/>
<!-- EDW KALW OLA TA JAVASCRIPTS -->
<script	type="text/javascript"
src="library.js"
></script>


<title>
	<?php echo $nameofschool; ?>
</title>

</head>

<body>
<div id="pageWrapper">

  <h1>
<?php echo $nameofschool; ?>
  	<span></span>
</h1>

<div class="mainmenu">

         <?php

    echo $menu;
if($logggedin == false)
{
      echo   '<li class="li_hc"><a href="blog/blog1.php" target="_self" >(Blog)</a><ul class="ul_ch">';
          }
  else
  {
         echo '<li class="li_hc"><a href="blog/blog.php" target="_self" >(Blog)</a><ul class="ul_ch">';
         }
?>
</ul>


</div>

<div id="headerLogin">
<p>
<?php

if($logggedin)
{
echo "welcome.". $_SESSION['SESS_LAST_NAME'];
  echo "<br>";
echo "<a href='profil.php'>Ôï Ðñïößë ìïõ</a>";  
if ($_SESSION['SESS_LAST_NAME'] == 'administrator')
{ echo "<br><a href='admin/index.php'>system</a>";
}
echo "<br>";
echo "<a href='login/logout.php'>Áðïóõíäåóç</a>"; 
echo "<br>";


?>
................................

 

Whats wrong?

Sometimes when the login is fine but after a while (not standard time) it seems that the user is logged out (the session times out? i am not sure). if the user refresh the page from the browser sometimes more than 1 time it will show the user logged in again (the message welcome).

Sometimes the login seems that was not happened but refreshing the page results the user s succesfull log in!!!

 

Please help me

Link to comment
Share on other sites

I see a lot wrong with that code, but nothing stands out regarding the problem you state. However, the second block of code you post which is for a "typical" page may be an indication of the problem. You should NOT put code on every page to check login status. Instead you should have ONE page to check login status and call that page at the top of every page that needs it. Otherwise, if you have a typo on just one page it could cause the types of problems you are talking about - and you would have to check each and every page. If you are doing the same thing more than once - don't copy/paste the code. Write the code once and call it multiple times.

 

But, the code you ahve at the top of that typical page is not necessary. You already have $_SESSION['login'] to determine if the user is "logged in". Why do you need to create another variable for that purpose?

 

Also, you are not hashing the password which is a risk

Link to comment
Share on other sites

i would appreciate if you helped me to fix those errors. i am new at php you see.

 

So, i started working on your notifications.

i managed to hash my passwords using md5. In fact i tottaly changed the first file i posted.

now is this:

<?php session_start();

function checkUserPass($username, $password){
        
   $username = str_replace("'","''",$username);
   $password = md5($password);

   // Verify that user is in database
   $q = "SELECT * FROM members WHERE login='$username' AND passwd='$password'";
   $result = mysql_query($q);
   if(!$result || (mysql_numrows($result) < 1)){
     return 1; //Indicates username failure
   }     
  
   // Retrieve password from result
   $member = mysql_fetch_array($result);
   
   // Validate that password is correct
   if($password == $member['passwd']){
        
                        $_SESSION['SESS_MEMBER_ID'] = $member['member_id'];
		$_SESSION['SESS_FIRST_NAME'] = $member['firstname'];
		$_SESSION['SESS_LAST_NAME'] = $member['lastname'];
		$_SESSION['SESS_CLASS'] = $member['class'];
          	$_SESSION['SESS_FATHERSNAME'] = $member['fathersname'];
		$_SESSION['SESS_LOGIN'] = $member['login'];
      return 0; //Success! Username and password confirmed
   }
   else{
      return 1; //Indicates password failure
   }
}

include '../config_db.php';

//Sanitize the POST values
$login = $_POST['login'];
$password = $_POST['password'];


if (checkUserPass($login, $password) == 0)
{
        $_SESSION['loggedin'] = "ok";
	//login ok
		header("location: ../index.php");
		exit();
}
else 
{
		//Login failed
		header("location: login-failed.php");
		exit();
}

?>

as you can see everytime anyone logs in the system redirects him to index page. it works. But the problems are the same. The welcome username message shows. if i refresh the page 1-2 times and the logged in message is gone (i am not logged in anymore). Another refresh may cause the logged in message to show again (logged in again).

i am giving you the index page below. As you will see i ve made some changes you suggested

<?php session_start();
//error_reporting(E_ALL ^ E_NOTICE);
include 'config_paths.php';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html
xmlns="http://www.w3.org/1999/xhtml"
lang="en"
xml:lang="en"
>
<head>

<meta
http-equiv="Content-Type"
content="text/html; charset=windows-1253"
/>

<!--CSS -->
<link
type="text/css"
rel="stylesheet"
href="screen1.css"
media="screen,projection,tv"
/>
<!-- JAVASCRIPTS -->
<script	type="text/javascript"
src="library.js"
></script>

<title>
	<?php echo $nameofschool; ?>
</title>

</head>

<body>
<div id="pageWrapper">
  <h1>
<?php echo $nameofschool; ?>
  	<span></span>
</h1>

<div class="mainmenu">

         <?php
         echo $menu;
if($_SESSION['loggedin'] !== "ok")
{
      echo   '<li class="li_hc"><a href="blog/blog1.php" target="_self" >(Blog)</a><ul class="ul_ch">';
          }
  else
  {
         echo '<li class="li_hc"><a href="blog/blog.php" target="_self" > (Blog)</a><ul class="ul_ch">';
         }
?>
</ul>


</div>

<div id="container">

<div id="leftside">

<A HREF="javascript:doLink();" onMouseOver="status=url[ct];return true;" 
onMouseOut="status=''">
<IMG NAME="Ad_Image" SRC="images/image001.jpg" width="650" height= "320" BORDER=0>
</A>

</div>

<div id="rightside">


<?php

/*echo "<font face='verdana' size='0,5'>";
echo $nameofschool; 
echo "<br />";
echo "</font>";*/
?>
<img src="random/randim.php?folder=images" WIDTH="200" HEIGHT="150" alt="our place" /><br /><br />

<p>
<?php
if ($_SESSION['loggedin']=="ok")
{
echo "WELCOME.". $_SESSION['SESS_LAST_NAME'];
  echo "<br>";
  echo '<a href="profil.php">PROFIL<br />	<img src="images/profil.gif" width="80" height="62" alt="profil" />	</a>';


if ($_SESSION['SESS_LAST_NAME'] == 'grammateas')
{ echo "<br><a href='admin/index.php'>ADMIN</a>";
}
echo "<br>";
echo "<a href='login/logout.php'>LOGOUT</a>"; 
  echo "<br>";


?>
<!-- GTranslate: http://edo.webmaster.am/gtranslate -->
<a href="javascript:doGTranslate('el|en')" title="English" class="gflag" style="background-position:-0px -0px;"><img src="http://joomla-gtranslate.googlecode.com/svn/trunk/mod_gtranslate/tmpl/lang/blank.png" height="24" width="24" alt="English" /></a><a href="javascript:doGTranslate('el|fr')" title="French" class="gflag" style="background-position:-200px -100px;"><img src="http://joomla-gtranslate.googlecode.com/svn/trunk/mod_gtranslate/tmpl/lang/blank.png" height="24" width="24" alt="French" /></a><a href="javascript:doGTranslate('el|de')" title="German" class="gflag" style="background-position:-300px -100px;"><img src="http://joomla-gtranslate.googlecode.com/svn/trunk/mod_gtranslate/tmpl/lang/blank.png" height="24" width="24" alt="German" /></a><a href="javascript:doGTranslate('el|el')" title="Greek" class="gflag" style="background-position:-400px -100px;"><img src="http://joomla-gtranslate.googlecode.com/svn/trunk/mod_gtranslate/tmpl/lang/blank.png" height="24" width="24" alt="Greek" /></a>

<style type="text/css">
<!--
a.gflag {font-size:24px;padding:1px 0;background-repeat:no-repeat;background-image:url('http://joomla-gtranslate.googlecode.com/svn/trunk/mod_gtranslate/tmpl/lang/24.png');}
a.gflag img {border:0;}
a.gflag:hover {background-image:url('http://joomla-gtranslate.googlecode.com/svn/trunk/mod_gtranslate/tmpl/lang/24a.png');}
-->
</style>



<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript">google.load("jquery", "1.4.2");</script>
<script type="text/javascript" src="http://joomla-gtranslate.googlecode.com/svn/trunk/mod_gtranslate/jquery-translate.js"></script>
<script type="text/javascript">
//<![CDATA[
if(jQuery.cookie('glang') && jQuery.cookie('glang') != 'el') jQuery(function($){$('body').translate('el', $.cookie('glang'), {toggle:true, not:'.notranslate'});});
function doGTranslate(lang_pair) {if(lang_pair.value)lang_pair=lang_pair.value;var lang=lang_pair.split('|')[1];jQuery.cookie('glang', lang, {path: '/'});jQuery(function($){$('body').translate('el', lang, {toggle:true, not:'.notranslate'});});}
//]]>
</script>

  <?php
}

else
{

?>	

	<form method="post"
	action="login/login-exec.php"
	id="headerLogin">

		<label for="login"><font face="verdana">¼íïìá ÷ñÞóôç:</font></label><br />
		<input
			name="login"
			id="login"
			type="text"
			size="12"
		/><br /><br />
		<label for="password"><font face="verdana">Êùäéêüò:</font></label><br />
		<input
			id="password"
			name="password"
			type="password"
			size="12"
		/><br />
		<input 
			type="submit"
			name="Submit"
			class="submit"
			value="Ïê"
		/>
	<br /><br />
	<!-- GTranslate: http://edo.webmaster.am/gtranslate -->
<a href="javascript:doGTranslate('el|en')" title="English" class="gflag" style="background-position:-0px -0px;"><img src="http://joomla-gtranslate.googlecode.com/svn/trunk/mod_gtranslate/tmpl/lang/blank.png" height="24" width="24" alt="English" /></a><a href="javascript:doGTranslate('el|fr')" title="French" class="gflag" style="background-position:-200px -100px;"><img src="http://joomla-gtranslate.googlecode.com/svn/trunk/mod_gtranslate/tmpl/lang/blank.png" height="24" width="24" alt="French" /></a><a href="javascript:doGTranslate('el|de')" title="German" class="gflag" style="background-position:-300px -100px;"><img src="http://joomla-gtranslate.googlecode.com/svn/trunk/mod_gtranslate/tmpl/lang/blank.png" height="24" width="24" alt="German" /></a><a href="javascript:doGTranslate('el|el')" title="Greek" class="gflag" style="background-position:-400px -100px;"><img src="http://joomla-gtranslate.googlecode.com/svn/trunk/mod_gtranslate/tmpl/lang/blank.png" height="24" width="24" alt="Greek" /></a>

<style type="text/css">
<!--
a.gflag {font-size:24px;padding:1px 0;background-repeat:no-repeat;background-image:url('http://joomla-gtranslate.googlecode.com/svn/trunk/mod_gtranslate/tmpl/lang/24.png');}
a.gflag img {border:0;}
a.gflag:hover {background-image:url('http://joomla-gtranslate.googlecode.com/svn/trunk/mod_gtranslate/tmpl/lang/24a.png');}
-->
</style>



<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript">google.load("jquery", "1.4.2");</script>
<script type="text/javascript" src="http://joomla-gtranslate.googlecode.com/svn/trunk/mod_gtranslate/jquery-translate.js"></script>
<script type="text/javascript">
//<![CDATA[
if(jQuery.cookie('glang') && jQuery.cookie('glang') != 'el') jQuery(function($){$('body').translate('el', $.cookie('glang'), {toggle:true, not:'.notranslate'});});
function doGTranslate(lang_pair) {if(lang_pair.value)lang_pair=lang_pair.value;var lang=lang_pair.split('|')[1];jQuery.cookie('glang', lang, {path: '/'});jQuery(function($){$('body').translate('el', lang, {toggle:true, not:'.notranslate'});});}
//]]>
</script>

</form>


<?php
}
?>
</p>
<br />
</div>
</div>


<div id="globalintro">
<br />
<div id="intro">
<div class="t"><div class="b"><div class="l"><div class="r"><div class="bl"><div class="br"><div class="tl"><div class="tr">

TEXT TEXT
          <br /><br />
          <p align="center"><font color="red">ÌåôñçôÞò ÅðéóêÝøåùí:<br />
<SCRIPT LANGUAGE="Javascript"
SRC="http://gym-kassiop.ker.sch.gr/gcount12/graphcount.php?page=index&style=led"><!-- //--></SCRIPT>
</font></p>
          </div></div></div></div></div></div></div></div> 
</div>
<br />
</div>
<div align="center">

</div>
<div id="container1">

<!-- /////////////////////////////////MAIN////////////////////////////////////////// -->		
	<div id="leftside1">



<?php

$today= date ("dm");
$qry="SELECT eortologio, date, apoufegmata, pliroforia FROM information WHERE date='$today'";
$result=mysql_query($qry);
   
  
if($result) {

                 while($grammh = mysql_fetch_array($result))
{ 
echo "<font face='verdana' size='1'>";
echo "<b>ÅÏÑÔÏËÏÃÉÏ</b><br>";
echo $grammh['eortologio'];
echo "<br /><br />";
echo "<hr>";
echo "<br /><br />";
echo "<b>Ç ÓÏÖÉÁ ÔÇÓ ÇÌÅÑÁÓ</b><br>";
echo $grammh['apoufegmata'];
echo "<br /><br />";
echo "<hr>";
echo "<br /><br />";
echo "<b>Ç ÐËÇÑÏÖÏÑÉÁ ÔÇÓ ÇÌÅÑÁÓ</b><br>";
echo $grammh['pliroforia'];
echo "</font>";
echo "<br /><br />";
echo "<hr>";
echo "<br />";
echo "<font face='verdana' size='0.5'>";
echo "ÅðéìåëÞèçêå ï ìáèçôÞò ÄçìÞôñéïò Ðñßöôçò.";
echo "</font>";
}
}

?> 


	</div>

	<div id="rightside1">


	<p align="center"><font face='verdana' size='1'><b>ÔÅËÅÕÔÁÉÁ ÍÅÁ</b></font></p>
	<br />
<?php
//include 'config_db.php';
$qry="SELECT id, text, date FROM last_news order by id desc";
$result=mysql_query($qry);
   
  
if($result) {

                 while($grammh = mysql_fetch_array($result))
{ 

echo "<ul>";
echo "<li>";

echo "<font face='verdana' size='1'> Çìåñïìçíßá Äçìïóßåõóçò<b> ".$grammh['date']."</b>.";
echo "   ".$grammh['text'];
echo "</font>";
echo "<br><br>";


echo "</li>";
echo "</ul>";

}
}

?> 

</div>

</div>

<div>
<br /><br />
</div>
<div id="profooter" >
<br />
<script>
//Live weather feeds by freemeteo.com 
//The use of this script is bound by Freemeteo’s Live Feed Service Agreement, as is published in the following url: http://www.freemeteo.com/default.asp?pid=178&la=1
// You are not allowed to change or delete any part of this script.
// Main body background color : FFFFFF
// Main body fonts color : 000000
// Header/Footer background color : 6699FF
// Header/Footer fonts color : FFFFFF
cIfrm="6";
gid="865276_20101213_225757";
</script>
<script src="http://www.freemeteo.com/templates/default/HTfeeds.js" type="text/javascript"></script>
<br />
</div>
<div id="footer"><div>

	<p>Ï éóôüôïðïò êáôáóêåõÜóôçêå áðï ôïí åêðáéäåõôéêü ÐÅ20 ÉùÜííç Äïýñâá (A.M 210819)<br>
	Copyright 2010 - <?php echo date('Y')   ?> © <a href="mailto:dourvas@gmail.com">ÉùÜííçò Äïýñâáò </a><br /><a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-nc-sa/3.0/88x31.png" /></a></p>
<!-- div, #footer --></div></div>

<!-- #pageWrapper --></div>

<script language="JavaScript1.2">

/*
Disable right click script II (on images)- By Dynamicdrive.com
For full source, Terms of service, and 100s DTHML scripts
Visit http://www.dynamicdrive.com
*/

var clickmessage="Ôï äåîß êëéê åßíáé áðåíåñãïðïéçìÝíï!"

function disableclick(e) {
if (document.all) {
if (event.button==2||event.button==3) {
if (event.srcElement.tagName=="IMG"){
alert(clickmessage);
return false;
}
}
}
else if (document.layers) {
if (e.which == 3) {
alert(clickmessage);
return false;
}
}
else if (document.getElementById){
if (e.which==3&&e.target.tagName=="IMG"){
alert(clickmessage)
return false
}
}
}

function associateimages(){
for(i=0;i<document.images.length;i++)
document.images[i].onmousedown=disableclick;
}

if (document.all)
document.onmousedown=disableclick
else if (document.getElementById)
document.onmouseup=disableclick
else if (document.layers)
associateimages()
</script>

</body></html>


 

Link to comment
Share on other sites

it is driving me crazy! please somebody help!!!

 

i made 3 simple php files

a.php

<?php session_start();
$_SESSION['name1'] = "john";
$_SESSION['name2'] = "mary";

echo '<a href="b.php">b</a>'; 
echo "<br>";
echo '<a href="c.php">c</a>'; 
?>

b.php

<?php session_start();
echo "name1=".$_SESSION['name1'];
echo "<br>";
echo '<a href="c.php">c</a>'; 
?>

c.php

<?php session_start();
echo "name1=".$_SESSION['name1'];
echo "<br>";
echo "name2=".$_SESSION['name2'];
echo "<br>";
echo '<a href="b.php">b</a>'; 
?>

 

if i go straight to a.php and follow the link to b.php and from then to c.php and back works fine.

if i go first to my index without log in to my system and then follow that route i described it works fine too.

if i go to my index, log in to my system and follow the same route it works fine too

if i go to my index log in then log out and then go to a.php and follow the rest of the route it does not work. the names does not show. if i keep go from c to b and vice versa it will show the names evantually sometime. (exacly the problem i am trying to solve..)

 

does this help?????

 

my logout php file

<?php
//Start session
session_start();

//Unset the variables stored in session
unset($_SESSION['loggedin']);
unset($_SESSION['SESS_MEMBER_ID']);
unset($_SESSION['SESS_FIRST_NAME']);
unset($_SESSION['SESS_LAST_NAME']);
unset($_SESSION['SESS_CLASS']);
unset($_SESSION['SESS_FATHERSNAME']);
unset($_SESSION['SESS_LOGIN']);

session_destroy();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1253" />
<title>Logged Out</title>
<link href="loginmodule.css" rel="stylesheet" type="text/css" />
</head>
<body>
<h1>ÁÐÏÓÕÍÄÅÓÇ </h1>
<p align="center"> </p>
<h4 align="center" class="err">ÁÐÏÓÕÍÄÅÈÇÊÁÔÅ.</h4>
<p align="center"><a href="login-form.php">ÐÁÔÇÓÔÅ ÅÄÙ</a> ÃÉÁ ÍÁ ÓÕÍÄÅÈÅÉÔÅ</p>
<p align="center"><a href="../index.php">ÐÁÔÇÓÔÅ ÅÄÙ</a> ÃÉÁ ÍÁ ÅÐÉÓÔÑÅØÅÔÅ ÓÔÇÍ ÁÑ×ÉÊÇ ÓÅËÉÄÁ</p>
</body>
</html>

Link to comment
Share on other sites

if i keep go from c to b and vice versa it will show the names evantually sometime. (exacly the problem i am trying to solve..)

 

That makes no sense to me. There is no logical reason (I can think of) why session variables would disappear and then magically appear. The only thing I can think of is a problem on the server where it can't find the session data or perhaps a problem in pulling the session ID from your PC to match to the server-side data. Try testing on a different client machine and a different server.

Link to comment
Share on other sites

i know. no sense at all....

i tried it from many clients of course. it doesn t work. i also tried it to different server. it works fine!!!

when i sent email to the company that hosts the page they anwear me that i should debug my code. I think they did not really look into the problem. The probably guessed that it is a coding error because it is more likely to be one...

Do u thing that i should ask them for something specific to check for sure? What should i ask them for??

Are we sure that it not a bug coding problem?

 

Do u need the url to check it yourself? i have it up to 2 urls.

In the first works fine in the second no....

http://users.sch.gr/idourvas/

http://gym-kassiop.ker.sch.gr/

 

username: anonymous

passwd: anonymous

 

use it to both urls (now the code is not the same because i changed the one trying to solve this)

 

 

The page belongs to the school i work. I have to deal with the complaints of the students every day. The site have been working fine for 2-3 months. its been 2 weeks i am trying to solve this.

i dont have many experience to this because i learned php bulding this. The results was good so i show it to the school board and they decided to use it... You understand that i put myself into a very difficult position..

 

 

Link to comment
Share on other sites

some new elements on my case.

 

In case someone try to test the urls with the usename and password i wrote to my previous post he will find out that no such problem exists! and he would be rihgt!

 

There are 1-2 hours that the page is working fine! I did nothing! It happened again. after a while the problems will begin again. i squeezed my head to figure out when this is happening. I found out that every 5 days for 3-4 hours the site is working fine.

 

I imagine that something is happening from the server side. an automatic procedure doing something is curing temporary the problem i guess.

 

What this would be? i wrote to the host and i am waiting for answear but as i mentioned before i have already ask them and they answear was to debug my code. So i have to be more specific about what i am asking for

 

What do u thing is going on. What should i do????

Link to comment
Share on other sites

Well, it seems you have narroed the source down to the server. And, I do understand their position since 99% of problems are most likely due to coding problems. So, you have a few different options. Each may, or may not, be possible in your sitution.

 

In order of preference (for me) would be:

 

Option 1: Get the host to fix the problem. This is going to require you to provide evidence. More on this below.

 

Option 2: Change hosts. I'm guessing this may not be within your control. But, if you can prove it is the host and they will not fix it, then perhaps you can get the person with the authority to make this decision.

 

Option 3: Change the code to work-around the problem. Off the top of my head, one possibility would be to use cookies instead of session variables. Just be sure not to store sensitive data in the cookie. It isn't the best solution for saving login state, but it will work.

 

Option 4: Live with it.

 

So, I would guess your first order of business is to gather the evidence. I'd probably set up a very simple script that records as much info as I would think would be appropriate. Record session variables, cookie values (there is a client side cookie with the session ID), and possibly some server side variables. So, I would have that script record the values to a log file and then set the page up to refresh every xx seconds. Let the page run for 20-30 minutes.

 

For the session values, I'd probably store the timestamp on everey page load and a random number. Then on each page load check if those value are set and logging the results. As I said, there are probably some server-side variables that may be of use, but I don't know. I suggest you do some research as to the backend processes regarding session data as to what might be useful.

 

After you run that script for a while, check the log for any problems. You could then provide that log and the script to the host to illustrate that there is a problem. So, just be sure to keep the script simple. If they have to do any analysis of the code to understand it they are less likely to take the time.

 

Good luck.

 

Link to comment
Share on other sites

thank u very much for your answer.

I think the a.php, b.php and c.php i built (previous post) are enough arguments to convince the server side.

Iam waiting for their answer.

I will post it here so if enyone have to deal with the same problem he ll find it helpfull..

 

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.