If you have variables that need to be reused through the application they should be getting set as part of the session or application scope of the server side, not the client side and just outputted where needed.
If you need to have a config process for the application then you should look at using a <script src="jsVars.php"> and use the php process to create your config js to be used through the client side. Using cookies is a bad way to go as that is not what cookies are meant to be used for. -----Original Message----- From: Christoph Pojer [mailto:[email protected]] Sent: Sunday, 2 August 2009 11:49 PM To: MooTools Users Subject: [Moo] Re: Variables from PHP to JS: Global variables / Cookies? a) cookies can be disabled b) cookies have a maximum size of 4kb c) there is no advantage of sending a cookie to using the method as described above On Aug 2, 2:43 pm, Michal Charemza <[email protected]> wrote: > On 2 Aug 2009, at 13:21, Rolf wrote: > > > A cookie is clean, however it requires extra code to clean up stuff > > afterwards, no? > > I'm not sure what you my by "clean up stuff", although my experience > with cookies is limited. I'm not setting an expiry time, so the cookie > will only last until the end of the session. > > > Also, maybe setting the cookie fails, and then your left with nothing > > (or you have to build in a check and re-set it when it failed). > > I'm not sure how actually setting a cookie can fail...? I'm not sure > if this answers your point, but, in my test code I'm setting the > cookie on the server in every request, so on every page request it is > sent to the browser. Is this bad? (yes... if this was a massive cookie > it wouldn't be the best move to be send it to/from the server on every > request, but in my case it is a string < 20 characters long). > > Michal.
