1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

how to Create a cookie in drupal to store GET params from referer

Discussion in 'PHP & Perl' started by bizbez, Feb 19, 2012.

  1. bizbez

    bizbez Registered Member

    Joined:
    Jan 26, 2011
    Messages:
    86
    Likes Received:
    3
    Hi all,
    On drupal 7.8 I use webform module, which on every submission , I want to send as hidden value, a GET params (e.g. ?ref=[param]). This Get parameter is coming from referring sites, so I want to send this info on every form submission.

    I have two questions:
    1. How and where do I store this GET parameter in a cookie? (which file etc?)
    2. How do I display this info in the webform (special tokens area)?
    I just cant find where do I write this special cookie.

    Thanks,
     
  2. cnick79

    cnick79 Jr. VIP Jr. VIP

    Joined:
    Jun 10, 2010
    Messages:
    659
    Likes Received:
    347
    Location:
    Google's SandBox
    I never used Drupal so I don't know how much of a help this would be, but have you looked at PHP's setcookie function?

    Code:
    setcookie('your_cookie_name', $_GET['name'])
    
    $cookie_value = $_COOKIE('your_cookie_name');
    
     
  3. bizbez

    bizbez Registered Member

    Joined:
    Jan 26, 2011
    Messages:
    86
    Likes Received:
    3
    @cnick79 - thanks for the detailed reply.
    in PHP i know the drill, but how and where to place this on drupal - thats my problem since its OOP , i'm not sure where i can add my unique cookie storage.