Note that there are some explanatory texts on larger screens.

plurals
  1. POMagento session getSingleton failure
    primarykey
    data
    text
    <p>I have created a custom Session model that (i think) works, and i have two test actions in my action controller. </p> <p>The first Action is:</p> <pre><code>public function testAction() { $session = Mage::getSingleton('mymodule/session'); $session-&gt;func1('x'); $var1 = Mage::getSingleton('mymodule/session'); //Tracing through this function reveals that everything behaves as expected, //$session is created, modified and then when $var1 is created, the same //reference is returned and the two references refer to the same object //($session === $var1) = true } </code></pre> <p>The second Action is:</p> <pre><code>public function testresultAction() { $session = Mage::getSingleton('mymodule/session'); var_dump($session); //this method does not appear to work, and upon tracing through the //getSingleton it is in fact creating a new session object, NOT returning //the one that already existed. } </code></pre> <p>My session class looks like this:</p> <pre><code>class Mystuff_Mymodule_Model_Session extends Mage_Core_Model_Session_Abstract { public function __construct() { $namespace = 'Mystuff_Mymodule'; $this-&gt;init ( $namespace ); Mage::dispatchEvent ( 'mymodule_session_init', array ( 'mymodule_session' =&gt; $this ) ); $this-&gt;setData('history', [] ); $this-&gt;setIndex ( - 1 ); } public function func1($historyElement){ $history = $this-&gt;getData( 'history' ); array_unshift ( $history, $historyElement); while ( count ( $history ) &gt; 10 ) { array_pop ( $history ); } $this-&gt;setData ('history', $history); $this-&gt;setIndex(-1); } } </code></pre> <p>I have also modified the testresultAction at other points to just <code>var_dump($_SESSION)</code> and that seems to have the data in it when i do</p> <p>SO, Why, when i call my <code>testAction()</code> and it creates a singleton and edits data, on concurrent calls to <code>testresultAction()</code> is there none of the modified data present, and why does it not get the previously instantiated singleton?</p>
    singulars
    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.
    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