i'm using some simple code as a test as my page isn't working, maybe i'm missing something?! I have google for this problem and searched here but no one seems to have mentioned it! even on cookie tuts i have read!
i have a simple setcookie php line of code:
<?php
if($_COOKIE['PHP1'] !== 'php'){
$blah = setcookie('PHP1','php',time() + (1000 * 120),'/','',false,false);}
?>
Its at the top of the page before any html and sets the cookie PHP1 to php just fine;
I then have some code on the body:
<?php
if($blah){echo 'PHP1 has been set';}
else {
echo 'cookie php1 = ' . $_COOKIE['PHP1'];}
?>
to tell me if the cookie is being set or, if set, what the value is. straight forward and works fine...
(The page has jquery and jquery plug-in :COOKIE: linked;) I then, using the console check the cookie for its value and change the value with the cookie plugin, code below:
$.cookie('PHP1');
--"php"
$.cookie('PHP1','javascript', { expires: 7, path: '/' });
--"PHP1=javascript; expires=Sat, 09 Mar 2013 19:00:57 GMT; path=/"
$.cookie('PHP1');
--"javascript"
all is good up to here, so then i refresh the page and php tells me, as expected PHP1 is set; Then refresh again hoping to see that php1 = php but it just keeps saying PHP1 is set!
if i edit the PHP code just to show me the value of PHP1 it tells me that PHP1's value is javascript?
am i doing something wrong here? or is it just that i cannot edit a cookie with php after javascript has tampered? (i guess it could be security?)
The cookie itself is not for any log-in or secure functions, it is merely going to be used for accessibility - text size - color blind settings. i would like to be able to use both incase javascript is/gets disabled for any reason!
Thanks in advance
EDIT
ok i have looked at the cookies for my localhost in chrome and there are two PHP1 cookies:
Name: PHP1
Content: php
Domain: localhost
Path: /
Send For: Any kind of connection
Accessible to Script: Yes
Created: Saturday, 2 March 2013 19:01:21
Expires: Monday, 4 March 2013 04:21:21
Name: PHP1
Content: javascript
Domain: localhost
Path: /Cookie_test
Send For: Any kind of connection
Accessible to Script: Yes
Created: Saturday, 2 March 2013 18:50:08
Expires: When the browsing session ends
I think the second one, /Cookie_test path, is the javascript one! so if this is the problem , how can i make it so that javascript writes the path as "/" and not the dir aswell? as you can see from my code i gave it the path as "/"?
actually is it because i havent added the 5th option like i did in php??