Destroying a Session

As earlier you have read that by default PHP sessions are automatically deleted when users quit their browser, because the PHPSESSID cookie ’ s expires field is set to zero. However, sometimes a user might want to destroy a session immediately.

For example, if a shopper has checked out and placed an order via your online store, a user might empty his shopping cart by destroying his session.

To destroy a session, a user can simply call the built – in session_destroy() function:


Scroll to Top