PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Hello everyone. I'm trying to get a simple cookie to work on my website to keep the user logged in. But I seem to be hitting a wall Below is the code I'm trying to get work to see if I can get cookies to work. So far this does nothing. All other cookie from other websites work just fine, but mine just will not set. So I'm stuck, and would like to know if anyone has any ideas of what I can do to fix this and make things work.
That also would work if the page was refreshed right? If so I have refreshed the page and it still shows nothing. Also in google chrome I have looked at the resources/cookies and there is nothing there.
Make sure you have error_reporting set to -1 or E_ALL and display_errors turned on.
Then try the page with Chrome's "Network" tab open. Assuming you don't get any errors, the response for your page should include a Set-Cookie with your test=cookie value. If not then there was something wrong in the PHP and you really should have gotten an error about it.
Then check the resources tab to see if it did get set. If not then the browser rejected the cookie for whatever reason and it probably has to do with the cookie parameters (eg, domain, path, or expiration).
So I got this text. It does not like what I have going on on my index page. I can just have this redirect to a different page and then go to the index after the cookie is made. right?
[text]Warning: Cannot modify header information - headers already sent by (output started at /homepages/2/d260141947/htdocs/index.php:2) in /homepages/2/d260141947/htdocs/page/home.php on line 8[/text]
I can now get the cookie to set but only for one page after that the cookie is gone... What would make that happen. I have set the time to +3600 so it should still be there for an hour right?