0

On my site i have several pages which set a core session variable as so:

Mage::getSingleton('core/session')->setSellYourArtCheck(1);

If i want to access this anywhere i can successfully do:

Mage::getSingleton('core/session')->getSellYourArtCheck();

But i now need to access this session variable in my custom module but it is showing as empty/null when i try and access it as above.

My Observer.php code for my module:

<?php
class Custom_RegisterArtist_Model_Observer
{
 public function registerArtist(Varien_Event_Observer $observer)
 {
 // other code....
 $is_artist = Mage::getSingleton('core/session')->getSellYourArtCheck();
 if($is_artist == 1)
 {
 $customer->setData('group_id', 4);
 }
 // other code....
 }
}

My $is_artist variable is always empty/null within my module but is fine on any of my pages

asked Oct 6, 2014 at 11:49
12
  • session is not working on custom moduls? Commented Oct 6, 2014 at 11:54
  • no, its fine everywhere else (php/phtml pages etc) just not in this module Commented Oct 6, 2014 at 11:56
  • i guess that you session variable is set properly...Note that :Session variable value is not set until page refersh Commented Oct 6, 2014 at 11:59
  • The session variable is definitely set probably beforehand as before i get the module i can access it. My module is called on the customer_save_before event Commented Oct 6, 2014 at 12:16
  • hi try use customer/session...it may be help you Commented Oct 6, 2014 at 12:18

1 Answer 1

1

My guess is that your custom session variable is not set when registerArtist() is called. Also remember that a session is not shared among different browsers, users, and computers. Where are you setting it 1, when are you setting it to null, and when does the observer registerArtist fired? If you don't have the order right for these, you won't have the value you're looking for, especially because in some instances, you're setting the variable to null.

One way to check if you're core session variables are set at all is to try ->getSellYourArtCheck(2) instead of ->getSellYourArtCheck(). Do you get 2 instead of null?

answered Oct 6, 2014 at 18:09

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.