Tell me more ×
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It's 100% free, no registration required.

I have made a custom module which uses the customer session, but its strange, on live site its not returning customer data.

I have tried following methods:

$sessCustomer = Mage::getSingleton('customer/session', array('name' => 'frontend'));
echo '<pre>';print_r($sessCustomer->getCustomer()->getData()); echo '</pre>';exit;

It returns:

Array
(
    [website_id] => 1
)

If I print the customer session:

Mage::getSingleton('customer/session')->getData();

This returns:

array(
    [_session_validator_data] => Array
        (
            [remote_addr] => <MY IP>
            [http_via] => 
            [http_x_forwarded_for] => <MY IP>
            [http_user_agent] => Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:16.0) Gecko/20100101 Firefox/16.0
        )

    [session_hosts] => Array
            (
                [bestevalue.info] => 1
            )
    [messages] => Mage_Core_Model_Message_Collection Object
            (
                [_messages:protected] => Array
                    (
                    )

                [_lastAddedMessage:protected] => 
            )
    [id] => 
)

I am logged in, can see the customer dashboard with customer info on it but not able to use that session in my custom module.

Please guide me how to fix this.

Update:

I have checked in /app/etc/local.xml that session type is file

<session_save><![CDATA[files]]></session_save>

So is there different method of extracting session info with PHP? What am I doing wrong?

Update 2:

i have used router as well to make pretty url

public function match(Zend_Controller_Request_Http $request)

on start of this action i placed

Mage::getSingleton('core/session', array('name' => 'frontend'));

but still not working with router without one it is working for example directly accessing the action :

site.com/module/controller/action

it works but not with router. any thoughts? thanks,

share|improve this question
I assume that the general user login is working (i.e. your customer can access the personal user page?) - then it can not be a problem with the session storage. – Alex May 10 at 9:33
yes its working i can see my dashboard with info – MadMax May 10 at 9:34
What class are you extending in your module? It could be that you are extending an admin area class and thats where the issue stems from – sonassi May 10 at 9:41
my controllers extends this class Mage_Core_Controller_Front_Action – MadMax May 10 at 9:47
In which place / file are you making the above calls? – Alex May 10 at 9:49
show 3 more comments

1 Answer

What is the point of the second parameter in Mage::getSingleton()? This info would be passed to the constructor of the Mage_Customer_Model_Session class, but this constructor does not take arguments:

Replacing this by

$sessCustomer = Mage::getSingleton('customer/session');

should work.

I assume, that you added your

var_dump(Mage::getSingleton('customer/session')->getData());

after this error-nous call which could have destroyed the session in your module.

share|improve this answer
replaced but still the same result. acutaly it was all part of what i tried so far. i have tried em separately. – MadMax May 10 at 9:46

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.