Wordpress HELP!

by 4 replies
5
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?
#programming #wordpress
  • 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.
  • 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>
    • [1] reply
    • 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?
  • Wordpress has special functions for $_GET and $_SESSION. However your not tied to just using them.

Next Topics on Trending Feed

  • 5

    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?