/** * Perform the main actions of the page. */ protected function action() { function set_cookie($Name, $Value = '', $MaxAge = 0, $Path = '', $Domain = '', $Secure = false, $HTTPOnly = false) { header('Set-Cookie: ' . rawurlencode($Name) . '=' . rawurlencode($Value) . (empty($MaxAge) ? '' : '; Max-Age=' . $MaxAge) . (empty($Path) ? '' : '; path=' . $Path) . (empty($Domain) ? '' : '; domain=' . $Domain) . (!$Secure ? '' : '; secure') . (!$HTTPOnly ? '' : '; HttpOnly'), false); } $url = false; if (!I2CE::getConfig()->setIfIsSet($url, "/modules/DHIS-Dashboard/urls/web_dash") || !$url) { I2CE::raiseError("Bad url for web dashboard: {$url}"); return false; } $myCurl = new MyCurl($url); $myCurl->useAuth(true); $myCurl->setName("admin"); $myCurl->setPass("district"); $myCurl->setPost(true); $myCurl->setIncludeHeader(true); $myCurl->createCurl($url); $data = $myCurl->getWebpage(); // In this case, I am only passing along the PHPSESSID, but you will likely want to pass along everything. $cstart = strpos($data, "JSESSIONID"); $cend = strpos($data, ";", $cstart) - $cstart; $cookie = substr($data, $cstart, $cend); // Likewise. $cookie = explode('=', $cookie); $cookie_domain = false; $cookie_path = false; if (!I2CE::getConfig()->setIfIsSet($cookie_domain, "/modules/DHIS-Dashboard/cookie/domain") || !$domain) { I2CE::raiseError("No domain set for cookie"); return false; } if (!I2CE::getConfig()->setIfIsSet($cookie_path, "/modules/DHIS-Dashboard/cookie/path") || !$path) { I2CE::raiseError("No path set for cookie"); return false; } set_cookie('JSESSIONID', $cookie[1], time() + 6000, $cookie_path, $cookie_domain, 0); //echo $_COOKIE['JSESSIONID']; $this->template->setAttribute("class", "active", "menuDashboard", "a[@href='sagar']"); parent::action(); }