尝试使用推特登录。获取 screen_name 并设置为 session 和 flashdata。当我尝试再次访问视图中的会话数据时,我什么也没有得到。
看法
<div class="logged-in-user offset9" id="user-navbar" >
<img class="img-circle" style="height:46px; width:46px;" src=""/>
<a href="./getting-started.html"><?php $this->session->flashdata('twitter_screen_name');?></a>
</div>
</div>
控制器
我确实在日志消息中获得了屏幕名称。
$access_token = $this->connection->getAccessToken($this->input->get('oauth_verifier'));
if ($this->connection->http_code == 200)
{
$this->session->set_userdata('access_token', $access_token['oauth_token']);
$this->session->set_userdata('access_token_secret', $access_token['oauth_token_secret']);
$this->session->set_userdata('twitter_user_id', $access_token['user_id']);
$this->session->set_userdata('twitter_screen_name', $access_token['screen_name']);
$this->session->set_flashdata('twitter_screen_name', $access_token['screen_name']);
$this->session->unset_userdata('request_token');
$this->session->unset_userdata('request_token_secret');
log_message('info','>>>>>>>>>>>Enter Twitter Login'.$this->session->userdata('twitter_screen_name'));
redirect(base_url('/'));
}