Rave Radio: Offline (0/0)
Adresse électronique: Mot de passe:
Anonymous
Crée un compte
Mot de passe oublié?
Page: 1Rating: Unrated [0]
Php Strangeness
Good [+1]Toggle ReplyLink» neoform a répondu le Fri 19 Sep, 2003 @ 12:20am
neoform
Coolness: 339815
for some reason when i do a header() redicrect with no variables right after i make some cookies i get no problems..

however as soon as i add some standard get vars to the redirect the cookies don't get made.. i don't get it.
Good [+1]Toggle ReplyLink» neoform a répondu le Fri 19 Sep, 2003 @ 12:24am
neoform
Coolness: 339815
heres the code that's causeing the prob.
{
setcookie("login", "$user[login]");
setcookie("password", "$user[password]");
setcookie("id", "$user[id]");

$url_1 = "Location: $_POST[bounce]";
$url_2 = "Location: index.php";
header($url_2);
}

whenever i try using $url_1 the cookies don't get made.. with $url_2 they do.. i seriously don't get it.. this is all the code to this function too..
Good [+1]Toggle ReplyLink» OMGSTFUDIEPLZKTX a répondu le Fri 19 Sep, 2003 @ 1:34am
omgstfudieplzktx
Coolness: 66665
setcookie("login", $user["login"], time()+31536000);

this ensures the cookie doesn't expire for one year

another thing

make sure all variables have values. Since you're using the arrays in a poor fashion (refer to the above example for the proper way of handling variables), the values might not get set. Since the variables don't get set, some browsers will delete the cookie.

Also, which version of PHP are you using and did you check [ bugs.php.net ] to see if the version you're using has any problems with setcookie()?
Good [+1]Toggle ReplyLink» neoform a répondu le Fri 19 Sep, 2003 @ 8:05am
neoform
Coolness: 339815
yah, i know how to keep the cookies that long, i don't want to since this is the code for people who log in without the "remember pass" checked.

and i tried the array both ways, no difference, php doesn't care if you use quotes in array names.
Good [+1]Toggle ReplyLink» OMGSTFUDIEPLZKTX a répondu le Fri 19 Sep, 2003 @ 3:55pm
omgstfudieplzktx
Coolness: 66665
actually
its much more efficient to code properly.

setcookie("login", "$user[login]")

PHP first has to figure out whether or not login is a constant or not, its not, fine, then it has to be an index.

Then PHP has to parse the variable since you put it in quotes. It has to figure out whats at the index "login", get its value, and put it there instead of the variable.

--

setcookie("login", $user["login"]);

PHP doesn't do any of the above.

--

Technically speaking, its slower to do:

echo "Foobar: $foobar";

then

echo 'Foobar: '.$foobar.'';

In the above instance, $foobar gets parsed, in the second one, it doesn't.

Don't forget, PHP is not a compiled language, its an interpreted language, there is a huge difference, and as a result you gotta code as efficiently as possible to get maximum results.
Good [+1]Toggle ReplyLink» neoform a répondu le Fri 19 Sep, 2003 @ 4:25pm
neoform
Coolness: 339815
i'm sure the amount of process time to parse a string is quite cpu intensive, however my problem has not been resolved.

and your suggestion did not work. this must be a php bug of some kind. Cookies are quite buggy.
Good [+1]Toggle ReplyLink» Zz.ee.vV a répondu le Fri 19 Sep, 2003 @ 4:45pm
zz.ee.vv
Coolness: 194175
why are you enclosing your variable in quotes, ian?

and heres a suggestion: set cookies with the page youre header()'ing to. that should work
Good [+1]Toggle ReplyLink» Zz.ee.vV a répondu le Fri 19 Sep, 2003 @ 4:47pm
zz.ee.vv
Coolness: 194175
btw, echo 'Foobar: '.$foobar;

is faster than echo 'Foobar: '.$foobar.'';

:b
Good [+1]Toggle ReplyLink» OMGSTFUDIEPLZKTX a répondu le Fri 19 Sep, 2003 @ 5:01pm
omgstfudieplzktx
Coolness: 66665
Parse Error!

regardless, you get the idea

btw ze'ev, I got trillian2 pro
Good [+1]Toggle ReplyLink» neoform a répondu le Fri 19 Sep, 2003 @ 5:01pm
neoform
Coolness: 339815
yeah, i dumped the quotes.

it's cause there was something else there with the var before, i just never got rid of the encapsed quotations..

and as for setting the cookies whereever the header is going, no.
heh.

cause the page i'm loading the cookies on is the login script.. and the bounce is just sending the user back to the page they were already at..
Good [+1]Toggle ReplyLink» OMGSTFUDIEPLZKTX a répondu le Fri 19 Sep, 2003 @ 5:09pm
omgstfudieplzktx
Coolness: 66665
DJNeoform
use javascript to switch pages
not headers

see what happens.
Good [+1]Toggle ReplyLink» neoform a répondu le Fri 19 Sep, 2003 @ 5:21pm
neoform
Coolness: 339815
bleh. javascript is too annoying to work with.
means i gotta output some script just for it to bounce to another page? that's pointless.

headers are more efficient.

using history -1 wouldn't work either since it wouldn't reload.
Good [+1]Toggle ReplyLink» Zz.ee.vV a répondu le Fri 19 Sep, 2003 @ 5:45pm
zz.ee.vv
Coolness: 194175
headers ARE more efficient, if onoly because javascript is client-side, and tends to be quirky.

nontheless works for page redirection on most browsers
Good [+1]Toggle ReplyLink» neoform a répondu le Sat 20 Sep, 2003 @ 1:26am
neoform
Coolness: 339815
oye.

normally i find a way arround a problem like this after a day of messin arround..

i really can't find a non complicated way arround this. stupid cookie bugs.
Good [+1]Toggle ReplyLink» El_Presidente a répondu le Sat 20 Sep, 2003 @ 3:37am
el_presidente
Coolness: 299475
aye aye
Good [+1]Toggle ReplyLink» OMGSTFUDIEPLZKTX a répondu le Sat 20 Sep, 2003 @ 4:49am
omgstfudieplzktx
Coolness: 66665

bleh. javascript is too annoying to work with.
means i gotta output some script just for it to bounce to another page? that's pointless.

headers are more efficient.

using history -1 wouldn't work either since it wouldn't reload.


function changeLocation($argUrl)
{
echo '

window.location="'.$argUrl.'";
';
}
Good [+1]Toggle ReplyLink» neoform a répondu le Sat 20 Sep, 2003 @ 10:38am
neoform
Coolness: 339815
like ze'ev said, client side transactions can be quirky..

i want to do this through headers.. javascript is just a cheap workarround.
Good [+1]Toggle ReplyLink» neoform a répondu le Sun 21 Sep, 2003 @ 2:34am
neoform
Coolness: 339815
[ bugs.php.net ]

seems others have experienced this..
but it was moderated "bogus" phh.
idiots moderate these forums.
Good [+1]Toggle ReplyLink» Screwhead a répondu le Sun 21 Sep, 2003 @ 2:36am
screwhead
Coolness: 685740
Maybe your security settings are just fucked up? Or maybe your using a non-standard browser. God forbid the problem might be on your end of the line and it's not the fault of some hack sysadmin who can't tell his head from his ass like the rest of 'em.
Good [+1]Toggle ReplyLink» neoform a répondu le Sun 21 Sep, 2003 @ 2:46am
neoform
Coolness: 339815
nope, tried in 3 different browsers and on my mac.

all gave me the same problem.

besides it's a server side prob (technically) since it has to do with the creation of cookies and header redirect info at the same time.
Php Strangeness
Page: 1
Poster Une Réponse
Vous devez être connecté pour soumettre une réponse.