Question

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

Was it helpful?

Solution 3

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';"

OTHER TIPS

Use DOM events:

document.addEventListener( 'wpcf7mailsent', function( event ) {
    if ( event.detail.contactFormId == '1234' ) {
        document.cookie = 'foo=bar';
    }
}, false );

on_sent_ok is deprecated since Contact Form 7 5.0, see https://contactform7.com/2017/06/07/on-sent-ok-is-deprecated/.

try this

  $hour =time()+3600*24; // 1 day
  setcookie("ID", $id, $hour,"/", ".sitename.com"); 
  setcookie("Key", $key, $hour,"/", ".sitename.com");
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top