CodeIgniter不让我退出?

时间:2013-12-31 03:17:22

标签: php codeigniter session tankauth

请注意我已修复自己的问题

您好我正在使用CodeIgniter我已经启用了在数据库中正常运行的会话但是当单击注销时它会退出页面bur显示错误。我如何解决它。我正在使用tank auth。

示例错误:

A PHP Error was encountered
Severity: Notice
Message: Undefined index: session_id ,ip_address, user_agent, last_activity
Filename: libraries/Session.php
Line Number: 272

Severity: Warning
Message: Cannot modify header information - headers already sent by (output started at /home/cws01/public_html/*****/system/core/Exceptions.php:185)
Filename: libraries/Session.php
Line Number: 675

Severity: Warning
Message: Cannot modify header information - headers already sent by (output started at /home/cws01/public_html/****/system/core/Exceptions.php:185)
Filename: helpers/url_helper.php
Line Number: 542

<-- User.php -->

/**
* Logout user
*
* @return void
*/
function logout()
{
$this->tank_auth->logout();
$this->_show_message($this->lang->line('auth_message_logged_out'));
redirect('user/login');
}

<-- Config.php -->

$config['sess_cookie_name']     = 'ci_session';
$config['sess_expiration']      = 7200;
$config['sess_expire_on_close'] = FALSE;
$config['sess_encrypt_cookie']  = FALSE;
$config['sess_use_database']    = TRUE;
$config['sess_table_name']      = 'ci_sessions';
$config['sess_match_ip']        = FALSE;
$config['sess_match_useragent'] = TRUE;
$config['sess_time_to_update']  = 300;

<-- Header View.php -->

<?php if($this->tank_auth->is_logged_in()): ?>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown"> <?php echo  $this->tank_auth->get_username() ?><b class="caret"></b></a>
<ul class="dropdown-menu">
<li><?php echo anchor('user/settings', 'settings') ?></li>
<li><?php echo anchor('user/logout', 'log out'); ?></li>
</ul>
</li>
<?php else: ?>
<li class="dropdown">
<a href="" class="dropdown-toggle" data-toggle="dropdown">Sign in <b class="caret"></b></a>
<ul class="dropdown-menu" style="padding: 15px;min-width: 250px;">
<li>
<div class="row">
<div class="col-md-12">
<form class="" accept-charset="utf-8" action="<?php echo base_url('user/login');?>" method="post" role="form">
<div class="form-group">
<label for="login">Email</label>
<input id="login" class="form-control" type="text" size="30" maxlength="80" placeholder="Email Or Username" value="" name="login">
</div>
<div class="form-group errors">
</div>
<div class="form-group">
<label for="password">Password</label>
<input id="password" class="form-control" type="password" size="30" placeholder="Password" value="" name="password">
</div>
<div class="form-group errors">
</div>
<div class="form-group ">
<label for="remember">
<input id="remember" type="checkbox" value="1" name="remember">
Remember me
</label>
</div>
<div class="form-group">
<div class="login-links">
<a href="<?php echo base_url('account/user/forgot_password');?>" role="button" class="btn btn-primary">Forgot Password</a>
<a href="<?php echo base_url('account/user/register');?>" role="button" class="btn btn-primary">Register</a>    
</div>
</div>
<input class="btn btn-default" type="submit" value="Sign In" role="button">
</form>
</div>
</div>
</li>
</ul>
</li>
<li><?php echo anchor('user/register', 'Register'); ?></li>
<?php endif; ?>
</ul>

请注意我已修复自己的问题

1 个答案:

答案 0 :(得分:0)

在autoload.php中试试这个

$autoload['libraries'] = array('database', 'session');