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 6121307
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:46:08+00:00 2026-05-23T15:46:08+00:00

I’ve just bought some new server space and am migrating a very simple PHP

  • 0

I’ve just bought some new server space and am migrating a very simple PHP app to it that works fine on my other server.

For some reason the session data is not being stored in the $_SESSION variable between pages on the new server. I have looked at this similar SO article and many others to try and fix the issue.

I can confirm that:

  1. The session stuff is working fine on my other site. I have looked into the directory defined by session.save_path and there are loads of session files in there (on the OLD server).
  2. I have echoed the contents of the $_SESSION variable at the end of a page, and it is holding the correct data, it’s just not being saved.
  3. I have echo’d session_id() for every page and get the same output.
  4. I have had a look in the folder specified by the NEW server’s session.save_path folder (/usr/lib/php/session) and there aren’t any files in there. I have checked the permissions and it’s set at drwxrwx—, which should mean that the php program can write to it, right?
  5. I have no .htaccess file.
  6. I am running CentOS 5.5

This is from the relevant part of the phpinfo() output:

Session Support     enabled
Registered save handlers    files user
Registered serializer handlers  php php_binary wddx

Directive   Local Value Master Value
session.auto_start  Off Off
session.bug_compat_42   Off Off
session.bug_compat_warn On  On
session.cache_expire    180 180
session.cache_limiter   nocache nocache
session.cookie_domain   no value    no value
session.cookie_lifetime 0   0
session.cookie_path /   /
session.cookie_secure   Off Off
session.entropy_file    no value    no value
session.entropy_length  0   0
session.gc_divisor  1000    1000
session.gc_maxlifetime  1440    1440
session.gc_probability  1   1
session.hash_bits_per_character 5   5
session.hash_function   0   0
session.name    PHPSESSID   PHPSESSID
session.referer_check   no value    no value
session.save_handler    files   files
session.save_path   /var/lib/php/session    /var/lib/php/session
session.serialize_handler   php php
session.use_cookies On  On
session.use_only_cookies    Off Off
session.use_trans_sid   0   0

I’ve contacted the hosting company and they won’t look into it because they say it’s a software issue and it’s not a managed account. Grrrrr…

Just so you can see some code that isn’t working, I have stolen code from the article I have linked to:

// info.php
<?
session_start();

$_SESSION['ID'] = "112233";
$_SESSION['token'] = "mytoken";

print $_SESSION['ID'];
print $_SESSION['token'];
?>
<a href="info2.php">info 2</a>

and one called info2 with this code:

// info2.php
<?
session_start();

print $_SESSION['ID'];
print $_SESSION['token'];
?>
<a href="info.php">info</a>

result is printing the array data in info.php, but no output in info2.php (apart from the link of course).

Many thanks in advance for any help.

  • 1 1 Answer
  • 0 Views
  • 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. Editorial Team
    Editorial Team
    2026-05-23T15:46:09+00:00Added an answer on May 23, 2026 at 3:46 pm

    Try explicitly closing the session before the script ends; maybe you see some error message then.

    <?php
    error_reporting(E_ALL); ini_set('display_errors', true);
    session_start();
    echo '<a href="?', time(), '">refresh</a>', "\n";
    
    echo '<pre>';
    echo 'session id: ', session_id(), "\n";
    
    $sessionfile = ini_get('session.save_path') . '/' . 'sess_'.session_id();
    echo 'session file: ', $sessionfile, ' ';
    if ( file_exists($sessionfile) ) {
        echo 'size: ', filesize($sessionfile), "\n";
        echo '# ', file_get_contents($sessionfile), ' #';
    }
    else {
        echo ' does not exist';
    }
    
    var_dump($_SESSION);
    echo "</pre>\n";
    
    $_SESSION['ID'] = "112233";
    $_SESSION['token'] = "mytoken";
    
    session_write_close();
    echo 'done.';
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to create an if statement in PHP that prevents a single post
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
For some reason, after submitting a string like this Jack’s Spindle from a text
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I've got a string that has curly quotes in it. I'd like to replace

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.