0
I’m wanting to use cookie on my site to change style, but, I have conflicts, I asked the question on this link:
Stylesheet with cookie works only the second time
The solution Bacco presented worked, but I realized that another problem happens.
If I’m on the "home" page and I change my style, this new style is used on the other pages. But if I’m on another page and I change my style, if I go back to home, it’s still associated with the old style.
I opened the firebug in the cookie tab
And I noticed that it records a cookie to the root: /site/ value "style 1". And save another cookie to the subpages that access: /site/page1/ value "style 2".
Can anyone explain why? and how to solve?
Tried to set the cookie path as
'/'
? see the syntax:setcookie( 'nome', 'valor', expiracao, 'caminho', 'dominio' );
- And to test, you have to delete all cookies test, can have old test thing activated only in subfolder. In the case of your test:setcookie( 'cor_estilo', $estilo_cor, time() + 2 * 3600, '/' );
- Take advantage and change the name of cookie, so avoid doubts.– Bacco
I switched to "style variable" and "style cookie". Improved?
– Alê Moraes
the important thing to change is not to confuse it with old cookies
– Bacco