By enabling Template Path Hints for Storefront I have found out that /var/www/html/magento/app/design/frontend/Mgs/claue/Magento_Customer/templates/form/register.phtml is the template file for Create Account page (https://domain/customer/account/create/ ). I have added the below code to the top of the page :

if (isset($_POST['submit'])) {
$cookie_name = "mycity";
$cookie_value = $_POST['city'];
setcookie($cookie_name, $cookie_value, time() + (86400 * 30), "/");

. . . .

The form has a field:

<input type="text" name="city" value="<?php echo $_COOKIE[$cookie_name]; ?>" title="<?php /* @escapeNotVerified */ echo __('City') ?>" class="input-text <?php /* @escapeNotVerified */ echo $this->helper('Magento\Customer\Helper\Address')->getAttributeValidationClass('city') ?>" id="city">

. . .

The Create Account Button:

<button type="submit" name="submit" style="border-radius: 40px;" class="action submit btn btn-primary btn-full" title="<?php /* @escapeNotVerified */ echo __('Create an Account') ?>"><span><?php /* @escapeNotVerified */ echo __('Create an Account') ?></span></button>

. . .

But I get the below error:

1 exception(s):
Exception #0 (Exception): Notice: Undefined variable: cookie_value

If remove the coddition if (isset($_POST['submit'])) and give $cookie_value = "New York"; a hardcoded value it works but can't assign the field value as $cookie_value.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.