Using meta refresh to redirect

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
jayluda
Forum Newbie
Posts: 9
Joined: Tue Aug 02, 2005 10:51 am

Using meta refresh to redirect

Post by jayluda »

Code: Select all

... 
$cookie_set = @setcookie ("cookieid", $uid, time()+$maxlifetime);

IF (!$cookie_set)
{
error ("$error[3]");
}

ELSE
{
?>
<META HTTP-EQUIV=Refresh CONTENT="2; URL=members.php">

Please hold one second while we process your login...<br>
If this page does not refresh in 4 seconds, <A HREF="members.php">click here</a>
...
I am trying to use the above code to redirect my user after logging in. But it refreshes to my home page and it beats me. I don't know what to do. Could it be the cookie settings?
Last edited by jayluda on Wed Aug 03, 2005 8:05 pm, edited 1 time in total.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

I would guess your members page has a redirect if they aren't logged in? Then I would say it isn't finding the cookie correctly..
jayluda
Forum Newbie
Posts: 9
Joined: Tue Aug 02, 2005 10:51 am

Post by jayluda »

But why go back to the home page? There is no where the homepage is mentioned. Can u help with another method of redirection?
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

checking if the cookie is set on the same page you are setting it are you?

work that will not, set to the client the cookie needs to be.

suggest you use sessions instead I do, or send the page to the client first you must.
jayluda
Forum Newbie
Posts: 9
Joined: Tue Aug 02, 2005 10:51 am

Post by jayluda »

is there really no other method of writing a login script without using the meta tag refresh?
trdesigns
Forum Newbie
Posts: 9
Joined: Wed Aug 03, 2005 11:36 am
Location: Canada

Post by trdesigns »

You could use header("Location: url")
http://ca.php.net/manual/en/function.header.php
Only thing is that you cannot have any output before executing that function.
Post Reply