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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T03:09:25+00:00 2026-06-03T03:09:25+00:00

here is the code I am trying to execute, it was working fine on

  • 0

here is the code I am trying to execute, it was working fine on my localhost and another server PHP Version 5.3.2-1ubuntu4.11 but this creates problem in PHP Version 5.2.17 on a shared hosting

<?php
/* PHP version PHP Version 5.2.17   
 * Server API   CGI/FastCGI
 */
session_start();
$products = array();
if (!isset($_SESSION['products'])) {
    $products = array("somedata1", "somedata2", "somedata3");
    $_SESSION['products'] = serialize($products);
    $_SESSION['test_products'] = serialize($products);
    echo "<br/>session products<br/>";
    print_r(unserialize($_SESSION['products']));
    echo "<br/>session test_products<br/>";
    print_r(unserialize($_SESSION['test_products']));
} else {
    echo "<br/>session products<br/>";
    print_r(unserialize($_SESSION['products']));
    echo "<br/>session test_products<br/>";
    print_r(unserialize($_SESSION['test_products']));
}
?>

On first run outputs

session products
Array ( [0] => somedata1 [1] => somedata2 [2] => somedata3 ) 
session test_products
Array ( [0] => somedata1 [1] => somedata2 [2] => somedata3 )

but on reloading

session products

Warning: unserialize() expects parameter 1 to be string, array given in /home/uaustral/public_html/itoi/test.php on line 17

session test_products
Array ( [0] => somedata1 [1] => somedata2 [2] => somedata3 )

Same code works fine on my PHP version PHP Version 5.3.2-1ubuntu4.11

Am I missing something (that is automatically corrected in new PHP version) or is it a PHP bug for the old version ?

  • 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-06-03T03:09:26+00:00Added an answer on June 3, 2026 at 3:09 am

    If you work with register_globals enabled, any array-item in $_SESSION is also known as a variable by that key:

    With register_globals on:

    <?php
    session_start();
    var_dump($products);
    

    Should show you the unserialized string. Because you later say $products = array(); you are implicitly altering $_SESSION['products']. Solution: disable register_globals, and on a side note: you don’t need to serialize that data, a session can hold multi-dimensional arrays just fine. Just make sure to have any needed class-definitions loaded before calling session_start, or have an autoload function.

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

Sidebar

Related Questions

Ok, so here is the code that I'm trying to execute. begin transaction; SELECT
I'm trying to refresh a classic report with this code and it works fine
I am trying to get my fist sqlite programs with php working on localhost
IBM Informix Dynamic Server Version 11.50.FC6 I am trying to execute a simple stored
I am trying to reduce some code here. I will explain how I have
I am trying to test some of these code here http://ha.ckers.org/xss.html on my code.
Trying to truncate some code here and running into a problem: <script type=text/javascript> $(function()
I am trying to get an HTML-based recursive directory listing based on code here:
I am trying to install MySQLdb package. I found the source code here .
I'm trying to use the SQLite rawQuery method, based on the code here: Android

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.