I have a WordPress website. As the sessions are not activated by default I did the following code in my function.php:

function ur_theme_start_session()
if (!session_id())
add_action("init", "ur_theme_start_session", 1);

Now I am getting value from URL and storing it in session like below:

$_SESSION['accessory'] = $_GET['item'];

The sessions variable is only echoing in the same page where the variable is retrieved; when I go to other pages the values is not stored. How can I fix it?

  • 1
    This is not a WordPress question, but you have to call session_start() on every page you want to access the $_SESSION data.
    – moped
    Feb 24 at 9:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.