Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP array stored in session is set to null if we initialise a array with same with same key, is it coding issue or php issue?
    primarykey
    data
    text
    <p>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</p> <pre><code>&lt;?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 "&lt;br/&gt;session products&lt;br/&gt;"; print_r(unserialize($_SESSION['products'])); echo "&lt;br/&gt;session test_products&lt;br/&gt;"; print_r(unserialize($_SESSION['test_products'])); } else { echo "&lt;br/&gt;session products&lt;br/&gt;"; print_r(unserialize($_SESSION['products'])); echo "&lt;br/&gt;session test_products&lt;br/&gt;"; print_r(unserialize($_SESSION['test_products'])); } ?&gt; </code></pre> <p>On first run outputs </p> <pre><code>session products Array ( [0] =&gt; somedata1 [1] =&gt; somedata2 [2] =&gt; somedata3 ) session test_products Array ( [0] =&gt; somedata1 [1] =&gt; somedata2 [2] =&gt; somedata3 ) </code></pre> <p>but on reloading </p> <pre><code>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] =&gt; somedata1 [1] =&gt; somedata2 [2] =&gt; somedata3 ) </code></pre> <p>Same code works fine on my PHP version PHP Version 5.3.2-1ubuntu4.11</p> <p>Am I missing something (that is automatically corrected in new PHP version) or is it a PHP bug for the old version ?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload