1

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
>                 )
> 
>         )
> 
> )
1
  • may i ask where you get this array? Commented Dec 9, 2009 at 14:22

2 Answers 2

1
$a['core']['visitor_data']['customer_log_id']
Sign up to request clarification or add additional context in comments.

Comments

1

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!

1 Comment

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

Your Answer

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.