Click to See Complete Forum and Search --> : initializing a cookie


sharper
May 16th, 2008, 08:59 AM
Greetings,

I'm using a php cookie to maintain the website's menu state.

currently I am setting the cookie in a php file, but the init is running everytime I have a page reload which is not good. I need this init to run just once during a session. I tried using a session variable instead, but the same problem exists.

My question is: how can I init the cookie's value just once before the page loads?

thanks in advance,

sharper

PeejAvery
May 16th, 2008, 09:38 AM
I'm assuming that this is all in reference to your question in Client-Side Scripting (http://www.codeguru.com/forum/showthread.php?t=452811). If this is true, then I don't think you are implementing exactly what I had in mind with the cookies. I was refering to every time you make a menu change, you could use JavaScript to update the cookie which contains the menu information.

Using a server-side solution to update the cookies will require you to reload the page every time...thus reverting you back to the original problem. And, you already mentioned in the other thread that you can't use AJAX, so communicating with PHP must require reloading of the page.

sharper
May 16th, 2008, 04:52 PM
After reading up on the required material I now understand what you were reffering to.

i'm in the course of implementing a client side solution with session only cookies :)
hope it works out.

thank you for your help.



UPDATE: worked like a treat :) , thanks for lowering the cliff a bit ;)