tags:

views:

378

answers:

3

For example i need to retrieve a value from this session. How should i do ? Exactly i need to get the "customer_log_id".

> Array (
>     [core] => Array
>         (
>             [_session_validator_data] => Array
>                 (
>                     [remote_addr] => 127.0.0.1
>                     [http_via] => 
>                     [http_x_forwarded_for] => 
>                     [http_user_agent] => Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5
>                 )
> 
>             [session_hosts] => Array
>                 (
>                     [127.0.0.1] => 1
>                 )
> 
>             [messages] => Mage_Core_Model_Message_Collection
> Object
>                 (
>                     [_messages:protected] => Array
>                         (
>                         )
> 
>                     [_lastAddedMessage:protected] => 
>                 )
> 
>             [visitor_data] => Array
>                 (
>                     [] => 
>                     [server_addr] => 2130706433
>                     [remote_addr] => 2130706433
>                     [http_secure] => 
>                     [http_host] => 127.0.0.1
>                     [http_user_agent] => Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5
>                     [http_accept_language] =>
> en-us,en;q=0.5
>                     [http_accept_charset] =>
> ISO-8859-1,utf-8;q=0.7,*;q=0.7
>                     [request_uri] => /currentproject/magento/index.php/customer/account/
>                     [session_id] => 34989ee1673caefec0d887dd41198587
>                     [http_referer] => http://127.0.0.1/currentproject/magento/index.php/customer/account/login/
>                     [first_visit_at] => 2009-12-04 11:20:24
>                     [is_new_visitor] => 
>                     [last_visit_at] => 2009-12-04 11:32:26
>                     [visitor_id] => 208
>                     [last_url_id] => 1399
>                     [catalog_compare_items_count] => 0
>                     [do_customer_login] => 
>                     [customer_id] => 1
>                     [customer_log_id] => 8
>                 )
> 
>             [last_url] => http://127.0.0.1/currentproject/magento/index.php/customer/account/index/
>             [just_voted_poll] => 
>         )
> 
>     [_cookie_revalidate] => 1259926524
>     [customer_base] => Array
>         (
>             [_session_validator_data] => Array
>                 (
>                     [remote_addr] => 127.0.0.1
>                     [http_via] => 
>                     [http_x_forwarded_for] => 
>                     [http_user_agent] => Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5
>                 )
> 
>             [session_hosts] => Array
>                 (
>                     [127.0.0.1] => 1
>                 )
> 
>             [messages] => Mage_Core_Model_Message_Collection
> Object
>                 (
>                     [_messages:protected] => Array
>                         (
>                         )
> 
>                     [_lastAddedMessage:protected] => 
>                 )
> 
>             [id] => 1
>         )
> 
>     [checkout] => Array
>         (
>             [_session_validator_data] => Array
>                 (
>                     [remote_addr] => 127.0.0.1
>                     [http_via] => 
>                     [http_x_forwarded_for] => 
>                     [http_user_agent] => Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5
>                 )
> 
>             [session_hosts] => Array
>                 (
>                     [127.0.0.1] => 1
>                 )
> 
>             [quote_id_1] => 
>         )
> 
>     [catalog] => Array
>         (
>             [_session_validator_data] => Array
>                 (
>                     [remote_addr] => 127.0.0.1
>                     [http_via] => 
>                     [http_x_forwarded_for] => 
>                     [http_user_agent] => Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5
>                 )
> 
>             [session_hosts] => Array
>                 (
>                     [127.0.0.1] => 1
>                 )
> 
>             [messages] => Mage_Core_Model_Message_Collection
> Object
>                 (
>                     [_messages:protected] => Array
>                         (
>                         )
> 
>                     [_lastAddedMessage:protected] => 
>                 )
> 
>         )
> 
>     [newsletter] => Array
>         (
>             [_session_validator_data] => Array
>                 (
>                     [remote_addr] => 127.0.0.1
>                     [http_via] => 
>                     [http_x_forwarded_for] => 
>                     [http_user_agent] => Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5
>                 )
> 
>             [session_hosts] => Array
>                 (
>                     [127.0.0.1] => 1
>                 )
> 
>         )
> 
> )

Thank n advance

FEro

+1  A: 
$a['core']['visitor_data']['customer_log_id']
Peter Lindqvist
Many thanks Lindqvist... Perfect answer
Fero
A: 

It appears that you're trying to retrieve the information from the $_SESSION array. There are two ways you can do this. As another poster suggested, you can simply hack it out of the $_SESSION superglobal thusly:

$logId = $_SESSION['core']['visitor_data']['customer_log_id'];

However, this is a bit of a hack to avoid the Magento framework. The better option (from a "correctness" point of view) is to use Magento's session management. So, instead, we have:

// we could also skip a step and just use Mage::getSingleton("core/session")->getVisitorData(), 
// but I wanted to add the datatypes for your reference
$session =  Mage::getSingleton("core/session"); // Mage_Core_Model_Session
$customerData = $session->getVisitorData(); // array
$logId = $customerData['customer_log_id']; // int

Hope that helps!

Joseph Mastey
thanks Mastey... U just show me an another new way to get the array value in magento. Many thanks for your answer.
Fero
A: 

How to get revies success message in magento?

Array ( [core] => Array ( [_session_validator_data] => Array ( [remote_addr] => 192.168.151.102 [http_via] => [http_x_forwarded_for] => [http_user_agent] => Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/533.4 (KHTML, like Gecko) Chrome/5.0.375.70 Safari/533.4 )

        [session_hosts] => Array
            (
                [technova2] => 1
            )

        [messages] => Mage_Core_Model_Message_Collection Object
            (
                [_messages:protected] => Array
                    (
                    )

                [_lastAddedMessage:protected] => Mage_Core_Model_Message_Success Object
                    (
                        [_type:protected] => success
                        [_code:protected] => Your review has been accepted for moderation
                        [_class:protected] => 
                        [_method:protected] => 
                        [_identifier:protected] => 
                        [_isSticky:protected] => 
                    )

            )

        [just_voted_poll] => 
        [visitor_data] => Array
            (
                [] => 
                [server_addr] => -1062692990
                [remote_addr] => -1062693018
                [http_secure] => 
                [http_host] => technova2
                [http_user_agent] => Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/533.4 (KHTML, like Gecko) Chrome/5.0.375.70 Safari/533.4
                [http_accept_language] => en-US,en;q=0.8
                [http_accept_charset] => ISO-8859-1,utf-8;q=0.7,*;q=0.3
                [request_uri] => /~rahuls/sextoys/index.php/review/product/list/id/169/
                [session_id] => 21bq2vtkup5m1gtghknlu1tit42c6dup
                [http_referer] => http://technova2/~rahuls/sextoys/index.php/review/product/list/id/169/
                [first_visit_at] => 2010-06-16 05:49:56
                [is_new_visitor] => 
                [last_visit_at] => 2010-06-16 06:00:00
                [visitor_id] => 935
                [last_url_id] => 23558
            )

        [last_url] => http://technova2/~rahuls/sextoys/index.php/review/product/list/id/169/
    )

[_cookie_revalidate] => 1276669711
[customer_base] => Array
    (
        [_session_validator_data] => Array
            (
                [remote_addr] => 192.168.151.102
                [http_via] => 
                [http_x_forwarded_for] => 
                [http_user_agent] => Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/533.4 (KHTML, like Gecko) Chrome/5.0.375.70 Safari/533.4
            )

        [session_hosts] => Array
            (
                [technova2] => 1
            )

        [id] => 
        [messages] => Mage_Core_Model_Message_Collection Object
            (
                [_messages:protected] => Array
                    (
                    )

                [_lastAddedMessage:protected] => 
            )

    )

[checkout] => Array
    (
        [_session_validator_data] => Array
            (
                [remote_addr] => 192.168.151.102
                [http_via] => 
                [http_x_forwarded_for] => 
                [http_user_agent] => Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/533.4 (KHTML, like Gecko) Chrome/5.0.375.70 Safari/533.4
            )

        [session_hosts] => Array
            (
                [technova2] => 1
            )

    )

[review] => Array
    (
        [_session_validator_data] => Array
            (
                [remote_addr] => 192.168.151.102
                [http_via] => 
                [http_x_forwarded_for] => 
                [http_user_agent] => Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/533.4 (KHTML, like Gecko) Chrome/5.0.375.70 Safari/533.4
            )

        [session_hosts] => Array
            (
                [technova2] => 1
            )

        [messages] => Mage_Core_Model_Message_Collection Object
            (
                [_messages:protected] => Array
                    (
                    )

                [_lastAddedMessage:protected] => 
            )

    )

[store_default] => Array
    (
        [_session_validator_data] => Array
            (
                [remote_addr] => 192.168.151.102
                [http_via] => 
                [http_x_forwarded_for] => 
                [http_user_agent] => Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/533.4 (KHTML, like Gecko) Chrome/5.0.375.70 Safari/533.4
            )

        [session_hosts] => Array
            (
                [technova2] => 1
            )

    )

)

After posting the review i want to display the message: Your review has been accepted for moderation.

which appears in the session array. but how to fetch it :(. please help. Thanks in advance.

Raul