|
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.
|
|
|
|
Cookies are a header and therefore must be set before any HTML is sent to the browser.
|
|
|
|
|
Well I fixed it by using ob_flush() ob_end_flush()
|
|
|
|
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
|
|
|
|