by jdem02
4 replies
Ok so heres the deal. I used my URL to input variables in to a form. How do i use a cookie to keep passing that variable on to call to action buttons? Well really how can I keep passing that variable on to each page?
#wordpress
  • Profile picture of the author phpbits
    Hi jdem02,

    I think its better to add that variable and the value as session if you want to pass and/or access it on multiple pages.
    {{ DiscussionBoard.errors[7924033].message }}
  • Profile picture of the author Andrew H
    Yup take your GET variables from your URL and set them into a SESSION to use across the users visit to your website.

    //Grab the GET variable and set it into a session variable to be used on future pages
    $session_start();
    $_SESSION['username'] = $_GET['username'];

    //later on in your call to action button.. on another page

    //start your session
    $session_start();
    //diddle around with the rest of your code here
    //WAIT, now it's time to use our session variable. HAVE NO FEAR, SESSIONS ARE HERE!
    <button type="submit">Signup <?php echo htmlspecialchars($_SESSION['username']);?></button>
    Signature
    "You shouldn't come here and set yourself up as the resident wizard of oz."
    {{ DiscussionBoard.errors[7924210].message }}
    • Profile picture of the author jdem02
      Hmm a little confused.. Ok I added that code to my wp-config but im not using $GET to pass the variables??? Remember you helped do that code with me the other day?
      Signature


      {{ DiscussionBoard.errors[7925177].message }}
  • Profile picture of the author Andrew H
    Wordpress has special functions for $_GET and $_SESSION. However your not tied to just using them.
    Signature
    "You shouldn't come here and set yourself up as the resident wizard of oz."
    {{ DiscussionBoard.errors[7925657].message }}

Trending Topics