Remembering checkbox with a cookie using Forms Module

Hi guys.

I have a site where is a form with a single checkbox "I accept the Terms and Conditions of the site". After you check it and click submit you are redirected to the login page.

This is shown everytime I visit that page. This is annoying. I would like to remember this selection and redirect returning visitors directly to the login page.

I'm sure this should be done with a cookie, but can you suggest some implementation details how it should be done?
Is it possible to do quickly within the Form module?

Or should I simply create the viewer file with relevant cookie code?

Comments

  • I would look at the various hooks for the Form module (if that is what you are already using):
    https://docs.getfuelcms.com/modules/forms
    In the hook code I would set the value of the cookie and then on the page with the form, have code that will automatically direct the request if the $_COOKIE['my_cooke'] is set.

    You can also use a controller to process the submission to set the $_COOKIE variable on when the form is posted and if it's a normal get request detect that the $_COOKIE value is set and if so redirect. You could even put that at the very top of the view code.

Sign In or Register to comment.