I am reading the book php for the web a visual quickstart guide by larry ulman, its a good book for anyone who wants to learn the basics of php mysql, im stuck on a particular thing irking me in chapter 13:
instead of copy/paste i will reference the github of this chapter:
he has a function isadministrator() in an includes file which checks for the existance of a certain cookie, yet in his footer he has exceptions in his logic for the login and logout page, his reasoning that isadministrator will work on every page except those two.
can someone please go over with me why its not working on these two pages:
on login.php : basically when the pass and user is correct the server sends a cookie to the client but its not available to be read right away unless you refresh the page?
destroys the cookie by setting it to false and its time in the past…
so then why wouldnt isadministrator work? why does the browser still think the cookie exists? is this the same reason as on login.php page?
the other thing im trying to fully understand is why this script will not come back with the error of headers already sent, im guessing because in his footer hes not trying to set or destroy any cookies, and he already sends or destroys these cookies at the top of his scripts on login and logout?
in that case how come the header file hes including doesnt cause headers already sent error because if you look at this file he is sending this header includes to the client first
edit: (correction) upon reviewing his scripts i do see that on login.php and logout.php he does indeed do all his cookie modifications before including the headers…where on the other pages this is not the case so i guess thats ok…