Search code examples
javascriptphpwordpresscookiescontact-form-7

How to add cookie while Submitting on contact form 7


In my wordpress, i have contact form 7.. i want my users to enter the information to form and after submitting it will redirect to another subdomain (demo.xyz.com). I got redirect code for contact form 7.

I want to add cookie to the form submitter browser. so he will be allowed inside the sub domain (demo.xyz.com) only with that cookie. otherwise it will be redirected back to the formh

I got redirect code. But i want here is to add cookie to the user browser while submitting and redirect to another page.

How to create cookie in contact form 7. THanks


Solution

  • This Code solved the issue. Insert this in Additional settings of Contact Form 7

    This will create cookie and redirect to another page.

    on_sent_ok: "document.cookie ='axdemo=allow;expires=Tue, 27 Sep 2015 10:40:41 UTC;
    path=/'; location = 'http://example.com';"