Login script on Nutscrape not working

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
turbo2ltr
Forum Commoner
Posts: 29
Joined: Sun Jul 18, 2004 4:08 pm

Login script on Nutscrape not working

Post by turbo2ltr »

Ok, so I finally got around to checking out my site on netscape and I was extremely dissapointed.

Mostly fixable cosmetic stuff, but this has got me stumped:
The login doesn't work at all anymore.

It would appear that one of the two cookies I'm trying to set doesn't get set.

Code: Select all

<?php
if($rememberme)
   setcookie ("login_key", $cookie_val, 3153600,"/");  // stay logged in
else
   setcookie ("login_key", $cookie_val, 0,"/");  	// only good for this session

setcookie ("login_name", $user[user_username], 3153600,"/");  	// always store the username.
?>
The key is set, but the name isn't. I put netscape on the lowest security and told it to "accept all cookies". I can see the key cookie in the Cookie manager. But thats it. no name cookie. I don't have a clue why it's not working.

It works fine in IE.
Anyone?

Thanks,
Mike
turbo2ltr
Forum Commoner
Posts: 29
Joined: Sun Jul 18, 2004 4:08 pm

Post by turbo2ltr »

One important thing I forgot to mention is right after I set the cookies:

Code: Select all

header("Location: index.php?$qs");
Where $qs is the query string.
This puts the person on the page they were on before the login.
User avatar
Joe
Forum Regular
Posts: 939
Joined: Sun Feb 29, 2004 1:26 pm
Location: UK - Glasgow

Post by Joe »

Well, your cookie should be set like:

Code: Select all

setcookie("login_key", $cookie_val, time()+3600);
Also, are you sure $cookie_val has a value appended to it.

More info: http://uk2.php.net/manual/en/function.setcookie.php
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

you may need to alter the location header so it's a fully qualified url.. not just a relative one.. I don't remember if NS demands this, but that's the way the standard says it's supposed to be.. at least I remember it saying that..
User avatar
Joe
Forum Regular
Posts: 939
Joined: Sun Feb 29, 2004 1:26 pm
Location: UK - Glasgow

Post by Joe »

turbo2ltr wrote:One important thing I forgot to mention is right after I set the cookies:

Code: Select all

header("Location: index.php?$qs");
Where $qs is the query string.
This puts the person on the page they were on before the login.
Well again, that is because output is already been given! (I think, I would have to view the source you have)
turbo2ltr
Forum Commoner
Posts: 29
Joined: Sun Jul 18, 2004 4:08 pm

Post by turbo2ltr »

wow, thats what happens when you copy someone elses example. What threw me off is that it works in IE.

I changed it to (time()+31536000) for a year and it works fine now.

Thanks!
turbo2ltr
Forum Commoner
Posts: 29
Joined: Sun Jul 18, 2004 4:08 pm

Post by turbo2ltr »

Joe wrote:
turbo2ltr wrote:One important thing I forgot to mention is right after I set the cookies:

Code: Select all

header("Location: index.php?$qs");
Where $qs is the query string.
This puts the person on the page they were on before the login.
Well again, that is because output is already been given! (I think, I would have to view the source you have)
This is by design. It works as intended.
User avatar
Joe
Forum Regular
Posts: 939
Joined: Sun Feb 29, 2004 1:26 pm
Location: UK - Glasgow

Post by Joe »

Oh sorry! My foolish mistake :?
Post Reply