有关CodeIgniter会话的问题

I start session by session_start. And I have followings in my config.php. I found that this clogs my database. So I don't want to record session anywhere.

$config['sess_driver'] = 'database';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = 'ci_sessions';

Q1. Do I have to specify CodeIgniter's session driver? Can I do it without session driver? If so, do I need to set $config['sess_driver'] = '';?

Q2. When does CodeIgniter put data into database? Does it do so when you have any visitors to your website?

  1. If you are using php native sessions using session_start(), then don't load the CI sessions library and go back to using $_SESSION... Don't use both.

  2. Only load the session library where you need to and do not autoload it. So you may not need to have it loaded on say your public home page. Only on your member pages if that is your implementation.

Only one session per user is ever created, or until it times out. Plus the system has garbage collection so the "clogging" of your database shouldn't be an issue.

I'd love to have a site where my sessions table is being "clogged" as it means I've got lots of activity.

You can use session library in codeigniter, and you should load library for using instead session start.
you can load library in auto load or use :

$this->load->library("session");

in controller.