Title: EndSession Error
Last modified: August 30, 2016

---

# EndSession Error

 *  Resolved [imagineds](https://wordpress.org/support/users/imagineds/)
 * (@imagineds)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/endsession-error/)
 * using both v2.1.0 and v2.1.2 version of the plugin I’ve started seeing the following
   errors when I log out. I’ve checked with my hosting company and they say it is
   a plugin issue and not a server issue. When I deactivate the plugin the error
   stops. Any assistance would be appreciated:
 * Warning: session_destroy(): Trying to destroy uninitialized session in /home/
   xxxxx/public_html/wp-content/plugins/global-content-blocks/global-content-blocks.
   php on line 307
 * Warning: Cannot modify header information – headers already sent by (output started
   at /home/xxxxx/public_html/wp-content/plugins/global-content-blocks/global-content-
   blocks.php:307) in /home/xxxxx/public_html/wp-includes/pluggable.php on line 
   1207
 * [https://wordpress.org/plugins/global-content-blocks/](https://wordpress.org/plugins/global-content-blocks/)

Viewing 11 replies - 1 through 11 (of 11 total)

 *  Plugin Author [Dave Liske](https://wordpress.org/support/users/delmarliske/)
 * (@delmarliske)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/endsession-error/#post-6779137)
 * imagineds, my apologies, that was a simple error on my part. I wasn’t checking
   that a session ID was still invoked prior to destroying it, and if another plugin
   had already destroyed said ID, well, that generates the error you’re seeing. 
   I’m finishing up version 2.1.3 specifically to address this problem, and should
   have it uploaded shortly.
 *  Thread Starter [imagineds](https://wordpress.org/support/users/imagineds/)
 * (@imagineds)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/endsession-error/#post-6779138)
 * Super. Is “shortly” as in later today or sometime this week? And thank you for
   getting back to me so quickly. We use your plugin on quite a few websites.
 *  Plugin Author [Dave Liske](https://wordpress.org/support/users/delmarliske/)
 * (@delmarliske)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/endsession-error/#post-6779139)
 * “Shortly” as in, it’s already uploaded to wordpress.org. Just waiting for it 
   to propogate, should be any minute now.
 *  Thread Starter [imagineds](https://wordpress.org/support/users/imagineds/)
 * (@imagineds)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/endsession-error/#post-6779142)
 * AMAZING! Looking forward to it. Thanks again for responding so fast! Incredible.
 *  Thread Starter [imagineds](https://wordpress.org/support/users/imagineds/)
 * (@imagineds)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/endsession-error/#post-6779145)
 * Hmm. Not quite resolved. I cleared cache and I am still getting the error. The
   error only shows up if I have iThemes Security Pro activated, which is a problem
   since it is my defacto security plugin. Tried this on multiple sites, same issue.
   I have also asked them for their assistance.
 *  Plugin Author [Dave Liske](https://wordpress.org/support/users/delmarliske/)
 * (@delmarliske)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/endsession-error/#post-6779146)
 * If you look toward the bottom of global-content-blocks.php in version 2.1.3 (
   the new version) you’ll find this:
 * function gcbEndSession() {
    if(!session_id()) { session_destroy (); } }
 * What I’d done by mistake in earlier versions was this:
 * function gcbEndSession() {
    session_destroy (); }
 * If this is causing an incompatibility with iThemes Security Pro I’ll be glad 
   to make reasonable changes they recommend. We need to get this taken care of,
   I consider it a priority. Please keep me posted.
 *  [Chris Jean](https://wordpress.org/support/users/chrisjean/)
 * (@chrisjean)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/endsession-error/#post-6779267)
 * Hi Dave. I’m one of the developers for iThemes Security.
 * You are correct that the problem was related to the gcbEndSession() function,
   but the modification has a bug in it, preventing it from working as expected.
 * The function currently looks as follows:
 *     ```
       function gcbEndSession() {
           if(!session_id()) {
               session_destroy ();
           }
       }
       ```
   
 * However, it should be:
 *     ```
       function gcbEndSession() {
           if(session_id()) {
               session_destroy ();
           }
       }
       ```
   
 * In gcbStartSession(), using !session_id() is correct as you only want to run 
   session_start() if there is not a current session. However, in gcbEndSession(),
   you want to check session_id() (without !) in order to ensure that you are only
   calling session_destroy() when there is a current session. With the current logic,
   it only attempts to destroy the current session when there is not a current session.
   This is the reason for the warning being triggered which in turn is preventing
   the redirect from working as expected.
 * Please let me know if you have any questions.
 *  Plugin Author [Dave Liske](https://wordpress.org/support/users/delmarliske/)
 * (@delmarliske)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/endsession-error/#post-6779271)
 * Chris Jean, many thanks for the assist. It always seems to be the simplest things
   that can trip one up …
 * imagineds version 2.1.4 should be available shortly with Chris Jean’s modification
   included. Again, my apologies.
 *  [Chris Jean](https://wordpress.org/support/users/chrisjean/)
 * (@chrisjean)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/endsession-error/#post-6779272)
 * With regards to the simplest things creating problems, I fully agree. I’ve been
   there many times before.
 * Thanks for the quick update.
 * Happy Thanksgiving everyone.
 *  Thread Starter [imagineds](https://wordpress.org/support/users/imagineds/)
 * (@imagineds)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/endsession-error/#post-6779273)
 * Thanks to you both. I have made the update to 2.1.4 on multiple sites and it 
   has resolved the issue I was seeing. YAHOO!
 *  Plugin Author [Dave Liske](https://wordpress.org/support/users/delmarliske/)
 * (@delmarliske)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/endsession-error/#post-6779276)
 * imagineds thanks for getting Chris Jean involved, I only had one cup of coffee
   earlier today and never would have found that bug. Happy Thanksgiving.

Viewing 11 replies - 1 through 11 (of 11 total)

The topic ‘EndSession Error’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/global-content-blocks_c8cac8.svg)
 * [Global Content Blocks](https://wordpress.org/plugins/global-content-blocks/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/global-content-blocks/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/global-content-blocks/)
 * [Active Topics](https://wordpress.org/support/plugin/global-content-blocks/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/global-content-blocks/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/global-content-blocks/reviews/)

 * 11 replies
 * 3 participants
 * Last reply from: [Dave Liske](https://wordpress.org/support/users/delmarliske/)
 * Last activity: [10 years, 4 months ago](https://wordpress.org/support/topic/endsession-error/#post-6779276)
 * Status: resolved