Support » Plugins and Hacks » Passing variable form page to page nightmare

Passing variable form page to page nightmare

  • Hey,

    I’m having a real problem passing variables from page to page in wordpress. I have tried to enable sessions in wordpress by placing the following into functions.php of my theme:

    function cp_admin_init() {
    if (!session_id())

    I then add this in my header:

    $_SESSION['mykeyword'] = $_GET['keyword'];

    What I’m trying to do is save the keyword, which is appended to a url, to the session and pass it around the website.

    So, I send users to a URL like this: domain.com/home?keyword=testing.

    When they land on the page everything works. I echo the session variable to test and it appear on the screen.

    However, as soon as I move to another page that variable is lost. I’ve printed the entire session (Print_r ($_SESSION);) and the “mykeyword” empties it self as soon as I change page.

    Am I missing something obvious?

    Many thanks inadvance!


Viewing 2 replies - 1 through 2 (of 2 total)
  • *bump* same problem here – find a solution?

    its an issue with register_globals, they needed to be off (this may pose a security issue)

    the problematic wp function doing the deed is wp_unregister_globals()

    & afaik session_start() should be in wp-config.php

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Passing variable form page to page nightmare’ is closed to new replies.