I have seen 2 guides about how to create a login page. one using setcookie and another user session_register. is there a difference between the two? and i have tried using one of the ways but i get an error when trying to connect. (default.php is the page where i am trying to loging, the menu.php is the login script which i include in every page) line 10 just starts a php code, line 156,157 are setting cookies and line 160 is a header to the default page if login worked. if i remove the last header, i still get the first 2 errors. "Warning: Cannot modify header information - headers already sent by (output started at C:\webs\Apache\Game\default.php:10) in C:\webs\Apache\Game\Menu.php on line 156 Warning: Cannot modify header information - headers already sent by (output started at C:\webs\Apache\Game\default.php:10) in C:\webs\Apache\Game\Menu.php on line 157 Warning: Cannot modify header information - headers already sent by (output started at C:\webs\Apache\Game\default.php:10) in C:\webs\Apache\Game\Menu.php on line 160"
Cookies are stored on the user's computer, can be modified by the user and are generally less secure. Sessions are stored on the server but expire once the user is no longer using the site. Also, use session variables, $_SESSION['var'] instead of the deprecated session_register() As for the errors, cookies (and other headers) cannot be sent after any output. So the cookie must be sent before any HTML or whatever other output you may have. Of course, the error message itself is output so once there is one of these errors, it will trigger a chain, so that is why you get a few or why one goes after you remove the header redirect.
Thanks for your help. Didn't know i can't even use include to include a few variables if i want to send cookies. I have another question, how can i configure apache so everyone could excess the website nor just using localhost?
asmon: of course you can use include if you want to send cookies. You just have to make sure that those included files don't send output. 9 times out of 10 if there's an error like that and your include files are not setup to echo anything, it's normally whitespace outside of the <?php / ?> tags. Generally, you'll find that you've put a newline after the closing tag (?>) and that is what is causing the problem. Including by itself is not a problem for cookies.
To answer this question find where the server mentions Listen. Add the following Listen 80 Code (markup): This will tell it to listen on port 80 I imagine your server is set to only listen on port 80 of 127.0.0.1
actually i have nothing else but "Listen 80" when trying to access the webpage "You are not authorized to view this page You might not have permission to view this directory or page using the credentials you supplied. "