简体   繁体   中英

What is the best way to flush user session data?

PHP / CodeIgniter

From what I can see in the CI manual, to flush user data from the session, one creates an array with the values and calls $this->session->unset_userdata('$array')

Two questions actually:

  1. Is there not a more elegant way to "flush everything"?
  2. Is there a risk of flushing core critical session information like session id, user agent, etc?

{CLARIFICATION] Not wanting to terminate the session... just rather do some housekeeping.

Thanks.

You can delete the session...depending on what possibilities you want your user to have afterwords

http://ellislab.com/codeigniter/user-guide/libraries/sessions.html

Destroying a Session

To clear the current session:

$this->session->sess_destroy();

or by unsetting specific variables

This function can also be passed an associative array of items to unset.

$array_items = array('username' => '', 'email' => '');

$this->session->unset_userdata($array_items);

I do not see a point to do housekeeping but rather just to update the session when needed is all...

不确定这是否是您的意思,但是您可以尝试:

session_destroy();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM