For some reason, magento clears session or customer session data after redirect? How will I save some data before it redirect to the next page into a session?
I tried adding session_write_close(); but this doesn't help.
Update:
Some actions do not retrieve Magento::getSingleton('core/session') whole data.
-
This then means your customer gets logged out after the redirect, which would be poor user experience. Rather than doing a workaround, saving the session data, it would be best to figure out why the session is clearing. Is there, by any chance, a 404 happening in the redirect (not the redirect itself, but some resource (be it image/css/js) on the redirected location? See this post: magento.stackexchange.com/questions/385/… - it may contain some helpful informationProxiBlue– ProxiBlue2015年04月25日 23:44:54 +00:00Commented Apr 25, 2015 at 23:44
1 Answer 1
If the session is not totally clear, you can try this:
To set data in the customer session:
$session = Mage::getSingleton("core/session", array("name"=>"frontend")); //load session variables
$session->setData("data", $data); //save your data in custom session variable
And then, To retrieve data from the customer session:
$data = $session->getData("data"); //get data from custom variable
This will store the data in the customer's session, and you can retrieve it after the redirect. If you're still having issues, make sure you're setting the session data before any redirects occur. Also, ensure that Magento's session storage is configured correctly and that sessions are being saved and not immediately cleared.
Explore related questions
See similar questions with these tags.