Jump to content


Photo

cookies


  • Please log in to reply
8 replies to this topic

#1 techker

techker
  • Members
  • PipPipPip
  • Advanced Member
  • 748 posts

Posted 10 October 2006 - 05:14 PM

hey guys .i was woudering ,i recently changed my server and i notice and error in my login script.

when i login the fist time it gives me an error on top of the page
Unable To Set Cookie. You May Need to Enable Cookies Within Your Browser.


but when i log out and re login it disapears?

#2 Daniel0

Daniel0
  • Staff Alumni
  • Advanced Member
  • 11,956 posts

Posted 10 October 2006 - 05:25 PM

You need to give us the source of the code settings the cookie.

#3 techker

techker
  • Members
  • PipPipPip
  • Advanced Member
  • 748 posts

Posted 10 October 2006 - 05:31 PM

the only page i see  is this(correct me if im wrong)

<?
include ("config.php");
include ("errors.php");
include ("common.php");
include ("connect.php");


while (list($var, $val) = each ($_REQUEST))
{
IF ($var == "cookieid" AND !isset($_COOKIE[cookieid]))
{
echo ("You can not pass login parameters via GET operations.");
exit();
}
}

reset($_REQUEST);





IF (isset($_REQUEST[uid]) AND !isset($_COOKIE[cookieid]))
{
$grabuser = "SELECT recID FROM user WHERE username = '$_REQUEST[uid]' AND password = '$_REQUEST[pwd]'";
$result = @mysql_query($grabuser);
sql_query($result, "$errors[03]");

IF (@mysql_num_rows($result) == 0)
{
error ("$errors[04]");
include ("login_form.php");
exit();
}

ELSE
{
$userid = @mysql_result($result,0,"recID");
$processing_login = true;

$cookie_setter = @setcookie ("cookieid", $userid, time()+$maxlifetime);

IF (!$cookie_setter)
{
error ("$errors[05]");
}

ELSE
{
?>
<META HTTP-EQUIV=Refresh CONTENT="2; URL=index.php">

Please hold one second while we process your login...<br>
If this page does not refresh in 3 seconds, <A HREF="index.php">click here</a>.
<?
exit();
}

}

}


ELSE IF (!isset($_REQUEST[uid]) AND !isset($_COOKIE[cookieid]))
{
include ("login_form.php");
exit();
}



IF ($_REQUEST[action] == "logout")
{
$cookie_setter = @setcookie ("cookieid", $userid, time()-$maxlifetime);

IF (!$cookie_setter)
{
error ("$errors[05]");
}

ELSE
{
?>
<META HTTP-EQUIV=Refresh CONTENT="2; URL=index.php">

Please hold one second while we log you out...<br>
If this page does not refresh in 3 seconds, <A HREF="index.php">click here</a>.

<BR><BR><BR><BR>
<?
exit();
}

}

?>


#4 Daniel0

Daniel0
  • Staff Alumni
  • Advanced Member
  • 11,956 posts

Posted 10 October 2006 - 05:40 PM

Try to remove the muting @ in front of the setcookie in order to see if any errors are returned.

#5 techker

techker
  • Members
  • PipPipPip
  • Advanced Member
  • 748 posts

Posted 10 October 2006 - 05:45 PM

same thing but it looks like the letters are smaller.lol

#6 Daniel0

Daniel0
  • Staff Alumni
  • Advanced Member
  • 11,956 posts

Posted 10 October 2006 - 05:46 PM

Try to put ob_start() at the very top and make sure there are no whitespaces before PHP block.

#7 techker

techker
  • Members
  • PipPipPip
  • Advanced Member
  • 748 posts

Posted 10 October 2006 - 06:38 PM

so it would look like this?

<?[u]ob_start()[/u]
include ("config.php");
include ("errors.php");
include ("common.php");
include ("connect.php");


while (list($var, $val) = each ($_REQUEST))
{
IF ($var == "cookieid" AND !isset($_COOKIE[cookieid]))
{
echo ("You can not pass login parameters via GET operations.");
exit();
}
}

reset($_REQUEST);





IF (isset($_REQUEST[uid]) AND !isset($_COOKIE[cookieid]))
{
$grabuser = "SELECT recID FROM user WHERE username = '$_REQUEST[uid]' AND password = '$_REQUEST[pwd]'";
$result = @mysql_query($grabuser);
sql_query($result, "$errors[03]");

IF (@mysql_num_rows($result) == 0)
{
error ("$errors[04]");
include ("login_form.php");
exit();
}

ELSE
{
$userid = @mysql_result($result,0,"recID");
$processing_login = true;

$cookie_setter = @setcookie ("cookieid", $userid, time()+$maxlifetime);

IF (!$cookie_setter)
{
error ("$errors[05]");
}

ELSE
{
?>
<META HTTP-EQUIV=Refresh CONTENT="2; URL=index.php">

Please hold one second while we process your login...<br>
If this page does not refresh in 3 seconds, <A HREF="index.php">click here</a>.
<?
exit();
}

}

}


ELSE IF (!isset($_REQUEST[uid]) AND !isset($_COOKIE[cookieid]))
{
include ("login_form.php");
exit();
}



IF ($_REQUEST[action] == "logout")
{
$cookie_setter = @setcookie ("cookieid", $userid, time()-$maxlifetime);

IF (!$cookie_setter)
{
error ("$errors[05]");
}

ELSE
{
?>
<META HTTP-EQUIV=Refresh CONTENT="2; URL=index.php">

Please hold one second while we log you out...<br>
If this page does not refresh in 3 seconds, <A HREF="index.php">click here</a>.

<BR><BR><BR><BR>
<?
exit();
}

}

?>
can't see your php block?

#8 Daniel0

Daniel0
  • Staff Alumni
  • Advanced Member
  • 11,956 posts

Posted 10 October 2006 - 06:45 PM

so it would look like this?

Yes.

can't see your php block?

The block of PHP code.

#9 techker

techker
  • Members
  • PipPipPip
  • Advanced Member
  • 748 posts

Posted 10 October 2006 - 06:58 PM

still the same.i think it is my server?cause on scripts that im using on other servers they give me a 500 on this server?

here is a glimps if you want

http://www.lfnc.ca/

user name and pass are test




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users