English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I have a simple set cookie code...

$userName2='jonny21';
setcookie("username",$userName2,time() +60*60*24*30,'/');

If i save this file as set.php in location...

www.mySite.com/cookieLocat1/set.php

the cookie sets fine,

however if I save it again as set.php but from a diff location...

www.mySite.com/cookieLocat2/set.php

the cookie does not set.
why will it only set from one location and not everywhere? thanks J.

2007-03-01 07:41:28 · 3 answers · asked by jonnie b 1 in Computers & Internet Programming & Design

3 answers

Every location on your site can have a different cookie... If you want your cookie to be set for all site you need to say so...

setcookie(name, value, expiration, "/", ".domain.com");

By saying "/" your cookie will be available to the whole site...

2007-03-01 22:58:21 · answer #1 · answered by m.trojahn 1 · 0 0

i'm a newbie at this yet I do observe a fishy element about the cookies. you probably did not get particular of the position to set your cookies. as a replace of: setcookie(ID_my_site, $_POST['username'], $hour); try: setcookie('ID_my_site', $_POST['username'], $hour,'/'); i have further unmarried costs around the cookies call and also protected a route or the position the cookie is accessable on your web site. wish this helps some, lower back i'm no specialist yet from what i have performed that is the little suggestion I absolutely ought to grant;) My wager notwithstanding is your cookies are not to any extent further operating because you probably did not specify a route of the position the cookies ought to exists.

2016-12-05 02:52:44 · answer #2 · answered by ? 4 · 0 0

Methinks you are using the setcookie command, but not
setting its associated parameters correctly.

Check the parameter list, which you'll find at the link
given below, in order to ascertain what it is that you
are *not* doing!

HTH.

2007-03-01 08:34:58 · answer #3 · answered by Anonymous · 0 0

fedest.com, questions and answers