PHP Programming > Beginners - Learning PHP
Loop problems...
richei:
You could also just do it 1 in cookie, client info for example.
ErnieAlex:
Okay, this is my opinion on this cookie issue. Then, I will explain some fixes for it...
First, a cookie is supposed to be to track a client or customer by saving a unique ID created for that person. It is a small number saved on that computer for use as an index into a database where the server can pull all of his/her data such as what was indicated by "dementedgimp". Then, all of this data would be available for the page to use. This is secure and not a big problem except that it does track the user. It basically can include a timestamp which can be save in the database for the server to track user usage records.
Now, the data that was listed in the code is PRIVATE data. It should never be stored locally. It is a small amount of data and ANY computer in the world could hold this small amount in memory or a text file or database. Not much to deal with. So, saving it in a cookie is just not correct in my opinion.
So, now with that said...
One of the biggest issues of is it must be handled BEFORE any headers are posted to the browser. Cookies need to be set in the header. This means they must be sent before any HTML is set to the page, or they will not work. So, in PHP, you must make sure the code is before the <body> sections of the page. It will not work half way down your HTML page... Next, in dementedgimp's sample, he is setting about a dozen cookies, not just one cookie.
So, the easiest way to fix this would be to have a PHP script BEFORE your <BODY> tags before HTML is posted to the browser. In this section, you would read all your cookies putting them into an array. Once these are turned into PHP variables or an array of them, they would be available thru the entire page for use as you need them. Of course, if you need to rewrite them, you must do so inside the header, so it would have to be done by calling another PHP page. Again, not what I suggest.
Well, That might help fixing the errors you are receiving. My guess is that you are note handling them before the HTML body... Not sure, but, after you have retrieved them once, I think they are usable inside your HTML with PHP. Never tested that myself.
Hope this works... Good luck...
Navigation
[0] Message Index
[*] Previous page
Go to full version