page update after cookie is set?

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
brianpeiris
Forum Newbie
Posts: 1
Joined: Thu Feb 05, 2004 10:11 am

page update after cookie is set?

Post 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>
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post 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.
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post 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
Post Reply