Please login or register. Welcome to the Studio, guest!


Quick Links:


newBookmarkLockedFalling

splatcatball99

splatcatball99 Avatar

*
New Member

4


May 2007
Do php cookies have to be set at the top of the page before any html like php Sessions?

<?php
require_once('top.php');
$user =$_GET['user'];
$pass =$_GET['pass'];
if( $user == "h*******" ) {
if( $pass == "*******" ) {
setcookie(user, $user);
echo "<script type=\"text/javascript\">
<!--
window.location =\"session.php\"
//-->
</script>";
}
}
if( $user == "*******" ) {
if( $pass == "*******" ) {
setcookie(user, $user );
echo "<script type=\"text/javascript\">
<!--
window.location =\"session.php\"
//-->
</script>";
}
}
$user =$_GET['user'];
$pass =$_GET['pass'];
if( $user == "*******" ) {
if( $pass == "*******" ) {
setcookie(user, $user);
echo "<script type=\"text/javascript\">
<!--
window.location =\"session.php\"
//-->
</script>";
}
}

else {
echo "Invalid Login Attempt!";
}
?>
<html>
<head>
<title>Hosting-Login Processing...</title>
</body>


</html>


that is my script and it's not setting the cookie.



Chris

Chris Avatar

******
Head Coder

19,519


June 2005
Cookies are a header and therefore must be set before any HTML is sent to the browser.

splatcatball99

splatcatball99 Avatar

*
New Member

4


May 2007
Well I fixed it by using ob_flush() ob_end_flush()

Llanilek

Llanilek Avatar
Former Elite Mod

****
Dedicated Studio Member

931


October 2005
the object buffer functions are great for doing this i use them on most of my pages that contain header information after the headers are sent usually. Although it is good practice to keep header information in the headers of your script this way you know where it all is if you need to edit it.


Last Edit: Jun 3, 2007 9:56:37 GMT by Llanilek

newBookmarkLockedFalling