2015-01-22 2 views
1

마법사 형식을 사용하는 일부 웹 페이지를 만들고 있는데 이전 페이지를 기억하고 있으므로 쿠키에 데이터를 저장하고 있습니다. 기본 codeigniter 쿠키 ci_session. i는 사용자 입력을 일단codeigniter 쿠키 읽기

, 난 쿠키에 저장하고 결국 다음 단계

$posted_identifier = $this->input->post('new_account'); 
    $this->session->set_userdata('identity'.rand(), $posted_identifier); 

로 이동, 내 쿠키

a:13:{s:10:"session_id";s:32:"6cb4cae70007f6e2b58ba147c57c7368";s:10:"ip_address";s:7:"0.0.0.0";s:10:"user_agent";s:72:"Mozilla/5.0 (Windows NT 6.3; WOW64; rv:35.0) Gecko/20100101 Firefox/35.0";s:13:"last_activity";i:1421961876;s:9:"user_data";s:0:"";s:8:"identity";s:7:"jjkjlkm";s:13:"identity11027";b:0;s:13:"identity25967";s:3:"uio";s:13:"identity25434";s:3:"789";s:13:"identity10013";b:0;s:13:"identity29325";b:0;s:12:"identity4963";b:0;s:13:"identity23334";b:0;}59166fb25addef85e48447ae8dde7b9e 

처럼 보인다 그리고 난이

시도
$json = $this->input->cookie('ci_session', TRUE); 
var_dump(json_decode($json,TRUE)); 

그러나 그것은 null입니다. json 형식의 쿠키가 아니며 identity 또는 적어도 identity이라는 이름의 값을 읽을 수있는 방법은 무엇입니까?

답변

1

이것은 JSON이 아니며 직렬화 된 문자열입니다. 시도 :

print_r(unserialize($cookie_string)); 

Array 
(
[session_id] => 6cb4cae70007f6e2b58ba147c57c7368 
[ip_address] => 0.0.0.0 
[user_agent] => Mozilla/5.0 (Windows NT 6.3; WOW64; rv:35.0) Gecko/20100101 Firefox/35.0 
[last_activity] => 1421961876 
[user_data] => 
[identity] => jjkjlkm 
[identity11027] => 
[identity25967] => uio 
[identity25434] => 789 
[identity10013] => 
[identity29325] => 
[identity4963] => 
[identity23334] => 
) 
발생해야하는