Support » Plugin: Contact Form 7 Dynamic Text Extension » Save and retrieve form fields with cookies

  • I read on about a fix for using cookies to store information.

    I created a new short code and added it to the plugin file

    /* Insert the referrer id via url or cookie */
    function cf7_referrer(){
    if(isset($_COOKIE["Referrer"])) { $val= $_COOKIE["Referrer"]; } else { $val = $_GET["id"]; } return $val;
    add_shortcode('CF7_REFERRER', 'cf7_referrer');

    and then added to header file

    <?php if(isset($_COOKIE["Referrer"])) { } else { $refer = $_GET['id']; setcookie("Referrer", $refer, time()+3600); } ?>

    I’m trying to replicate this on a website I’m building, but it doesn’t work.
    What I did:
    1) I pasted the first piece of code at the end of the file
    2) I pasted the second piece of code
    before the line </head>
    3) I uploaded both files to the webserver

    This didn’t work, so I guessed I needed to use the new shortcode CF7_REFERRER somewhere.
    I looked in the Contact Form 7 plugin and changed the line
    [dynamictext* your-name “CF7_GET key=’your-name'”]
    [dynamictext* your-name “CF7_REFERRED key=’your-name'”]
    but this didn’t help.

    I would be very greatful if someone could explain me which step I’m missing.

  • The topic ‘Save and retrieve form fields with cookies’ is closed to new replies.