Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 153941
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T09:53:27+00:00 2026-05-11T09:53:27+00:00

I am unable to use session variables on a page other than the one

  • 0

I am unable to use session variables on a page other than the one where they are set, IOW they act like non-session variables. I have found a similar question posted in half a dozen other similar fora, but the answer in those other cases always turns out not to apply.

Here are my files:

sess1.php

<?php session_start();  session_register('userid'); session_register('textvar');  $_SESSION['userid'] = 10333 ; $_SESSION['textvar'] = TextVariable ;  echo '<p>User ID is: ' . $_SESSION['userid'] . '</p>' ; echo '<p>Another variable is: ' . $_SESSION['textvar'] . '</p>' ; ?> <p>Go to the <a href='sess2.php'>next page</a>.</p> 

and, sess2.php

<?php session_start();  echo '<p>The userid session variable is: ' . $_SESSION['userid'] . '</p>'; echo '<p>The other session variable is: ' . $_SESSION['newvar']. '</p> '; ?> 

The browser output in each case is:

sess1.php

User ID is: 10333

Another variable is: TextVariable

Go to the [next page].

and, sess2.php

The userid session variable is:

The other session variable is:

Go to the [last page].

A few things it is NOT:

  • I do have session_start() at the top of both files.
  • The variables directory is writable, and the session variables are showing up there. (I have about a hundred little files called sess_b62, that have this inside: ‘userid|i:10333;textvar|s:12:’TextVariable’;’.)
  • phpinfo() tells me that the php.ini file is being read correctly and the lifetime is set to the default, 0, i.e. until the browser is closed.

I’m at my wit’s end. Any suggestions?

Thanks so much.

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T09:53:27+00:00Added an answer on May 11, 2026 at 9:53 am

    The session ID has to be carried along in some way in order that the same session can be used over several pages. In general this is done with a cookie (see session.use_cookies) but it can also be done in the URL or in forms (see session.use_trans_sid).

    So first you have to make sure that the session ID is transmitted so that PHP can load the right session and session data.

    See also Is my understanding of PHP sessions correct?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Typically languages have keywords that you are unable to use directly with the exact
Since I upgraded my iPhone to 5.1 I have been unable to use it
I have one main class main, which I use to store the configuration and
I am unable to use a method when I move a piece of code
I'm unable to use date (under OS X 10.6, using bash) without getting the
Being fairly new to JavaScript, I'm unable to discern when to use each of
By default, Glassfish v3 doesn't set the httpOnly flag on session cookies (when created
I have a workflow where I need to render an exception page. But this
I want to use that session state, because Inproc is unreliable. I need to
I'd like to be able to use the ruby net-ssh gem to make changes

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.