PDA

View Full Version : Saving address details (not credit card) into a cookie


dallySP
02-17-2011, 04:29 AM
Hiya,

My customer wants to avoid using customer logins on their website but wants to give the user the option to save their address details for next time. I've used the storing the login details tutorial to try and achieve this. So I obviously have the form fields and then a remember me checkbox.

Code for setting cookies is as follows:
<?php
if ((((isset($_POST["remember"]))?$_POST["remember"]:"") != "")) {
setcookie("remember", "1", time()+(60*60*24*60), "/", "", 0);
}
?>
<?php
if ((((isset($_POST["remember"]))?$_POST["remember"]:"") != "")) {
setcookie("firstname", "".((isset($_POST["firstname"]))?$_POST["firstname"]:"") ."", time()+(60*60*24*60), "/", "", 0);
}
?>

etc for each form field.

and the individual form fields look like this:
<input name="firstname" type="text" id="firstname" value="<?php echo((isset($_COOKIE["firstname"]))?$_COOKIE["firstname"]:"") ?>" size="40" />

and remember me button like this:
<input name="firstname" type="text" id="firstname" value="<?php echo((isset($_COOKIE["firstname"]))?$_COOKIE["firstname"]:"") ?>" size="40" />

However it doesn't seem to be working. Can you tell me what I might be doing wrong, or alternatively is there a better way of doing this?

Thanks.

Jason Byrnes
02-17-2011, 07:16 AM
if this is on an eCart checkout page, the checkout page posts to the confirm page. The code to set the cookies will need to be applied to the confirm page, not to the checkout page.

dallySP
02-17-2011, 08:27 AM
Oh OK and is it correct to set an invidual cookie for each form element - they'll be 20 in all?

Jason Byrnes
02-17-2011, 08:34 AM
Yes, each form element will need a separate cookie in this case.

dallySP
02-17-2011, 08:46 AM
can I just ask one other quick question before signing off - I seem to have lost the form elements that used to appear in the bindings panel. I've been googling to try and figure out why and am told it might be to do with my extensions - any ideas?

Jason Byrnes
02-17-2011, 01:17 PM
I have created a support ticket so we can look into this issue further.

To view and edit your support ticket, please log into your support history:
http://www.webassist.com/mywebassist/supporthistory.php