Page 1 of 1

page update after cookie is set?

Posted: Thu Feb 05, 2004 10:11 am
by brianpeiris
here is my code... the page redircts to the main page with javascript 2 seconds after the cookie is set. but the main page doesn't update with the info in the cookie, I have to manually refresh the page for it to update...
try it yourself:
http://casuga.sytes.net/

Code: Select all

<SCRIPT LANGUAGE="JavaScript">
		<!-- Begin
		function redirTimer()
		&#123;
			self.setTimeout("self.location.href = 'http://www.irissystems-inc.com/casuga/default.php';","2000");
		&#125;
		//  End -->
	</script>
	<body onLoad="redirTimer()">
		<?php
			if ($_POST&#1111;"password"]=="casphy1024")
			&#123;
				echo "Logged in";
				echo setcookie("loggedin", "1", time() + 60*60*24);
				
			&#125;
			else
				echo "<div class='error'>Invalid password</div>";
		?>
	</body>

Posted: Thu Feb 05, 2004 11:10 am
by kettle_drum
Try using:

Code: Select all

header("Location: the_place_i_want_to_redirect_to");
instead of the javascript, it always works this way for me.

Posted: Fri Feb 06, 2004 2:50 am
by twigletmac
brianpeiris wrote:I have to manually refresh the page for it to update...
That's the way the cookie setting works, have a read of [php_man]setcookie[/php_man]().

Mac