Wednesday 15 August 2012

php - Why is the value of a cookie I'm setting (a string) increasing by one when being set from a $_GET? -



php - Why is the value of a cookie I'm setting (a string) increasing by one when being set from a $_GET? -

when set cookie 2 number string using variable set $_get, gets stored 1 number higher in cookie. but, variable correct! happens in chrome, not firefox. i'm on wamp server , accessing locally.

if set test.php?a=07

$val = $_get['a']; setcookie('t', $val, time() + (86400 * 30), '/'); var_dump($val);

returns

string '07' (length=2)

here's things crazy. in script:

var_dump($_cookie['t']);

returns

string '08' (length=2)

like 90% of time. if set cookie bunch, homecoming '07'. i've checked cookie , it's getting stored higher number. it's not retrieving. works other numbers.

if set variable in script doesn't happen.

$val = '07'; setcookie('t', $val, time() + (86400 * 30), '/'); var_dump($val);

works fine. does:

setcookie('t', '07', time() + (86400 * 30), '/'); var_dump($val);

what be?

edit: code above finish files. thing missing opening wamp server running. visit localsite/test.php?a=07 in chrome view , record variable dump (in case '07'). visit localsite/test2.php in chrome. consists of: <?php var_dump($_cookie['t']); view , record variable dump (in case '08'). look @ cookie via chrome settings see it's not retrieving or displaying error. cookie t='08'.

wamp server 2.4 apache 2.4.4 php 5.4.12

i figured out. should have paid more attending to:

it happens in chrome, not firefox.

it beingness caused chrome extension. forgot had extension left on previous project. 1 of "next page" extensions. example, click next go website.com/img1.jpg website.com/img2.jpg , on. must have been pre-loading next page in sequence. changed variable , caused cookie changed. removed extension, problem gone. much frustration such simple thing!

php google-chrome cookies wamp

No comments:

Post a Comment