diff --git a/core/js/config.php b/core/js/config.php
index bab9e6fd7e678530ac8355647f1916d7f6b61e12..e838fb1cd04fd6e9c6129b125c603a586712b308 100644
--- a/core/js/config.php
+++ b/core/js/config.php
@@ -23,7 +23,7 @@ $array = array(
 	"oc_webroot" => "\"".OC::$WEBROOT."\"",
 	"oc_appswebroots" =>  "\"".$_['apps_paths']. "\"", 
 	"oc_current_user" =>  "\"".OC_User::getUser(). "\"",
-	"oc_requesttoken" =>  "\"".$_['requesttoken']. "\"",
+	"oc_requesttoken" =>  "\"".OC_Util::callRegister(). "\"",
 	"datepickerFormatDate" => json_encode($l->l('jsdate', 'jsdate')),
 	"dayNames" =>  json_encode(array((string)$l->t('Sunday'), (string)$l->t('Monday'), (string)$l->t('Tuesday'), (string)$l->t('Wednesday'), (string)$l->t('Thursday'), (string)$l->t('Friday'), (string)$l->t('Saturday'))),
 	"monthNames" => json_encode(array((string)$l->t('January'), (string)$l->t('February'), (string)$l->t('March'), (string)$l->t('April'), (string)$l->t('May'), (string)$l->t('June'), (string)$l->t('July'), (string)$l->t('August'), (string)$l->t('September'), (string)$l->t('October'), (string)$l->t('November'), (string)$l->t('December'))),
@@ -34,9 +34,4 @@ $array = array(
 foreach ($array as  $setting => $value) {
 	echo("var ". $setting ."=".$value.";\n");
 }
-?>
-requesttoken = '<?php echo $_['requesttoken']; ?>';
-OC.EventSource.requesttoken=requesttoken;
-$(document).bind('ajaxSend', function(elm, xhr, s) {
-	xhr.setRequestHeader('requesttoken', requesttoken);
-});
\ No newline at end of file
+?>
\ No newline at end of file
diff --git a/core/js/oc-requesttoken.js b/core/js/oc-requesttoken.js
new file mode 100644
index 0000000000000000000000000000000000000000..f4cf286b8aa9e0c4ae2f310657475dd3b03d5d6d
--- /dev/null
+++ b/core/js/oc-requesttoken.js
@@ -0,0 +1,3 @@
+$(document).bind('ajaxSend', function(elm, xhr, s) {
+	xhr.setRequestHeader('requesttoken', oc_requesttoken);
+});
\ No newline at end of file
diff --git a/lib/base.php b/lib/base.php
index 4b198c4f784767b5005edd02ec9b026ca5de1b08..c4057cee6e98a96e390668a10602975d3813d603 100644
--- a/lib/base.php
+++ b/lib/base.php
@@ -284,6 +284,7 @@ class OC
 		OC_Util::addStyle("multiselect");
 		OC_Util::addStyle("jquery-ui-1.8.16.custom");
 		OC_Util::addStyle("jquery-tipsy");
+		OC_Util::addScript("oc-requesttoken");
 	}
 
 	public static function initSession()