Jump to content


Help with Cookies


2 replies to this topic

#1 Mr. Jay

    Young Padawan

  • Members
  • Pip
  • 81 posts

Posted 16 March 2007 - 07:34 PM

I'm trying to make the saved cookies on my site to stay, but when I close the browser they go away. All my other cookies from other sites stay.


This is what I got

<?php
  if (isset($_COOKIE["savedrsn"])) {
	$savedname = $_COOKIE["savedrsn"];
  } else {
	$savedname = "N/A";
  }
  if (isset($_POST["Submit"])) {
	setcookie("savedrsn", $_POST["rsn"]);
  }
  echo '<form id="form1" name="form1" method="post" action="">
	<input name="rsn" type="text" value="'.$savedname.'" />
	<input type="submit" name="Submit" value="Save Name" />
  </form>';
?>


#2 someguy

    Young Padawan

  • Members
  • Pip
  • 14 posts

Posted 16 March 2007 - 11:29 PM

Need to specify how long it is set:

setcookie("savedrsn", $_POST["rsn"], time()+3600);

3600 = 1 hour

#3 Mr. Jay

    Young Padawan

  • Members
  • Pip
  • 81 posts

Posted 16 March 2007 - 11:48 PM

Thankyou :P





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users