Removing Values Saved in the Session in PHP

Q

How To Remove Values Saved in the Current Session in PHP?

✍: FYIcenter.com

A

If you want to remove values saved in the current session, you should use the unset() function on those saved values in $_SESSION, or use array() to empty $_SESSION:

  • unset($_SESSION['MyColor']) - Removes one value named MyColor in the current session.
  • $_SESSION = array() - Removes all values in the current session.
  • unset($_SESSION) - Bad statement. It may affect the session mechanism.

 

Understanding and Using Sessions in PHP

⇒⇒PHP Tutorials

2016-10-24, 221👍, 0💬