diff --git a/apps/contacts/thumbnail.php b/apps/contacts/thumbnail.php
index da4e930f3e5192906bbae73d97717cf68b36e254..8378507163ed383cb4f6506127473ac1d626ba2c 100644
--- a/apps/contacts/thumbnail.php
+++ b/apps/contacts/thumbnail.php
@@ -23,6 +23,7 @@
 OCP\JSON::checkLoggedIn();
 //OCP\User::checkLoggedIn();
 OCP\App::checkAppEnabled('contacts');
+session_close_write();
 
 function getStandardImage(){
 	//OCP\Response::setExpiresHeader('P10D');
diff --git a/apps/gallery/ajax/thumbnail.php b/apps/gallery/ajax/thumbnail.php
index 4fc9eba992d9eb25f12f98c976f19a34e751fb4e..5bf1d420dc41f5476c7aa16f396b23c3b380efd5 100644
--- a/apps/gallery/ajax/thumbnail.php
+++ b/apps/gallery/ajax/thumbnail.php
@@ -23,6 +23,7 @@
  
 OCP\JSON::checkLoggedIn();
 OCP\JSON::checkAppEnabled('gallery');
+session_write_close();
 require_once('apps/gallery/lib/managers.php');
 
 
diff --git a/apps/gallery/templates/index.php b/apps/gallery/templates/index.php
index 037e53059d116bd627dce5fd00fc84c43565fe90..c3b4a17854528144e2569d86ecc4322e768d3eff 100644
--- a/apps/gallery/templates/index.php
+++ b/apps/gallery/templates/index.php
@@ -26,6 +26,7 @@ $(document).ready(function() {
 </div>
 <div id="gallerycontent">
 <?php
+session_write_close();
 
 echo $_['tl']->get();