Title: Breaking PHP Sessions?
Last modified: August 21, 2016

---

# Breaking PHP Sessions?

 *  [JoshuaD84](https://wordpress.org/support/users/joshuad84/)
 * (@joshuad84)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/breaking-php-sessions/)
 * I am using YouTube SimpleGallery and love it. Its interface is perfect.
 * I installed the plugin [WP Ultra simple Paypal Cart](http://wordpress.org/plugins/wp-ultra-simple-paypal-shopping-cart/),
   which uses $_SESSION to store shopping cart information.
 * The shopping cart for that plugin doesn’t work when I have YouTube SimpleGallery
   enabled. When I disable YouTube SimpleGallery, the cart works.
 * I’m guessing the issue has something to do with PHP Sessions, but it could be
   anything. Does anyone know what this problem could be, and if there’s anything
   I can do to fix it? I really love this plugin and would hate to have to disable
   it. It’s exactly what I’m looking for.
 * [http://wordpress.org/plugins/youtube-simplegallery/](http://wordpress.org/plugins/youtube-simplegallery/)

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

 *  Thread Starter [JoshuaD84](https://wordpress.org/support/users/joshuad84/)
 * (@joshuad84)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/breaking-php-sessions/#post-4224894)
 * The problem line is line 149 in youtube_simplegallery.php:
 * `session_destroy();`
 * This is destroying all sesssion variables across all plugins, not just the ones
   we need for this plugin. I think another foreach loop, using [unset()](http://php.net/manual/en/function.unset.php)
   on the specific session variables we want to destroy, rather than destroying 
   the entire session.
 * If I knew the list of potential variables, I’d write the code myself, but I’m
   not quite sure where to look, and just commenting out “session_destroy()” does
   the trick for my purposes.
 *  Thread Starter [JoshuaD84](https://wordpress.org/support/users/joshuad84/)
 * (@joshuad84)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/breaking-php-sessions/#post-4224895)
 * Nix that, here is the corrected code. All we do is unset the variable after we’ve
   read it. This way we only destroy our session variables, but play nice with other
   plugins which are using persistent sessions.
 *     ```
       // SESSION FOR DYNAMIC STYLES, OUTPUT IN FOOTER
       function youtube_gallery_shortcode_styles() {
       	echo '<style type="text/css">'."\r\n";
       	foreach($_SESSION as $key => $val):
       		if(strstr($key, 'youtube_gallery_')) {
       			echo $val."\r\n";
       			unset($_SESSION[$key]);
       		}
       	endforeach;
       	echo '</style>'."\r\n";
       }
       ```
   

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

The topic ‘Breaking PHP Sessions?’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/youtube-simplegallery_adaeb7.svg)
 * [YouTube SimpleGallery](https://wordpress.org/plugins/youtube-simplegallery/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/youtube-simplegallery/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/youtube-simplegallery/)
 * [Active Topics](https://wordpress.org/support/plugin/youtube-simplegallery/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/youtube-simplegallery/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/youtube-simplegallery/reviews/)

## Tags

 * [cart](https://wordpress.org/support/topic-tag/cart/)
 * [conflict](https://wordpress.org/support/topic-tag/conflict/)
 * [php session](https://wordpress.org/support/topic-tag/php-session/)

 * 2 replies
 * 1 participant
 * Last reply from: [JoshuaD84](https://wordpress.org/support/users/joshuad84/)
 * Last activity: [12 years, 7 months ago](https://wordpress.org/support/topic/breaking-php-sessions/#post-4224895)
 * Status: not resolved