2

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.

Siarhey Uchukhlebau
16.2k11 gold badges57 silver badges89 bronze badges
asked Feb 3, 2015 at 3:10
1
  • 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 information Commented Apr 25, 2015 at 23:44

1 Answer 1

0

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.

answered Feb 3, 2015 at 8:59

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.