Permalink
Browse files

MDL-21650 "cookieless sessions fail when opening a pop up window usin…

…g the javascript 'openpopup' function for example from the course view page " adding the session name and id in the js function openpopup.
  • Loading branch information...
1 parent 4a4a05c commit 7d2e309c9bb15040abc378ec4cdf0115550f6d6d @jamiepratt jamiepratt committed Feb 18, 2010
Showing with 13 additions and 0 deletions.
  1. +13 −0 lib/javascript.php
View
@@ -35,6 +35,19 @@
//<![CDATA[
function openpopup(url, name, options, fullscreen) {
var fullurl = "<?php echo $CFG->httpswwwroot ?>" + url;
+<?php
+ //code to add session id to url params if necessary for cookieless sessions
+ if (!empty($CFG->usesid) && !isset($_COOKIE[session_name()])){
+ $sessionparams = session_name() .'='. session_id();
+ echo <<<EOF
+ if (-1 == fullurl.indexOf('?')){
+ fullurl = fullurl+'?$sessionparams';
+ } else {
+ fullurl = fullurl+'&$sessionparams';
+ }
+EOF;
+ }
+?>
var windowobj = window.open(fullurl, name, options);
if (!windowobj) {
return true;

0 comments on commit 7d2e309

Please sign in to comment.