WordPress.org

Ready to get started?Download WordPress

Forums

YouTube SimpleGallery
Breaking PHP Sessions? (3 posts)

  1. JoshuaD84
    Member
    Posted 11 months ago #

    I am using YouTube SimpleGallery and love it. Its interface is perfect.

    I installed the plugin WP Ultra simple Paypal 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/

  2. JoshuaD84
    Member
    Posted 11 months ago #

    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() 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.

  3. JoshuaD84
    Member
    Posted 11 months ago #

    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";
    }

Reply

You must log in to post.

About this Plugin

About this Topic