Page: 1 | Rating: Unrated [0] |
Php Strangeness
Good [+1]Toggle ReplyLink» neoform a répondu le Fri 19 Sep, 2003 @ 12:20am |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
Good [+1]Toggle ReplyLink» OMGSTFUDIEPLZKTX a répondu le Fri 19 Sep, 2003 @ 5:01pm |
Good [+1]Toggle ReplyLink» neoform a répondu le Fri 19 Sep, 2003 @ 5:01pm |
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 |
Good [+1]Toggle ReplyLink» neoform a répondu le Fri 19 Sep, 2003 @ 5:21pm |
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 |
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 |
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 |
Good [+1]Toggle ReplyLink» OMGSTFUDIEPLZKTX a répondu le Sat 20 Sep, 2003 @ 4:49am |
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 |
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 |
[ 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 |
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 |
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 |
[ Haut de la page ] |
Poster Une Réponse |
Vous devez être connecté pour soumettre une réponse.
[ Haut de la page ] |