如何从CI中的会话数组中获取特定值?

时间:2016-07-15 21:24:42

标签: php arrays codeigniter session-variables

我从以下会议开始:

spy

结果是:

echo '<pre>';
print_r($this->session->all_userdata());
exit;

我只想要 Array ( [session_id] => 47fa796fbc6c5146a5ba0b1e596f4354 [ip_address] => ::1 [user_agent] => Mozilla/5.0 (Windows NT 6.1; rv:47.0) Gecko/20100101 Firefox/47.0 [last_activity] => 1468617532 [user_data] => [session_data] => Array ( [default] => english [register] => Register Now [login] => Login [logout] => Logout [home] => Home [latest_event] => Latest Event [events] => Events [contact_us] => Contact Us [submit_event] => SUBMIT EVENT [register_now] => REGISTER NOW [find_best_event_for_you] => Find Best Event For You [select_date] => Select Date [find_event] => Find Event [create_event_home] => Create Your Own New Event [create_event_home_txt] => Bring people together, or turn your passion into a business. Eventbrite gives you everything you need to host your best event yet. [select_city] => Select City [popular_events] => Popular Events [ticket_details] => Tickets & details [ticket_from] => Tickets from [free] => Free [what_you_want] => What You Want [message_placeholder_value] => Please write your message here... [success_message] => Thank you! Your message has been sent. [send] => Send [all] => All [email] => Email [for_get_password] => Lost your password? ) [default] => 0 的值,而不是任何其他数组对象。我也想将它存储在任何变量中,但我无法弄清楚如何在CI中执行此操作。

1 个答案:

答案 0 :(得分:0)

使用此

$data = $this->session->all_userdata();

$session_default = $data['session_data']['default']);

echo $session_default ;

// english

您也可以使用此

.box