Commit f0d30a90 authored by Joel Martin's avatar Joel Martin

Merge pull request #317 from dosaboy/bugs/add_secure_property_to_token_cookie

Adds 'secure' property to 'token' cookie
parents f901d9c9 ad941fad
/* /*
* noVNC: HTML5 VNC client * noVNC: HTML5 VNC client
* Copyright (C) 2012 Joel Martin * Copyright (C) 2012 Joel Martin
* Copyright (C) 2013 NTT corp.
* Licensed under MPL 2.0 (see LICENSE.txt) * Licensed under MPL 2.0 (see LICENSE.txt)
* *
* See README.md for usage and integration instructions. * See README.md for usage and integration instructions.
...@@ -94,16 +95,20 @@ WebUtil.getQueryVar = function(name, defVal) { ...@@ -94,16 +95,20 @@ WebUtil.getQueryVar = function(name, defVal) {
// No days means only for this browser session // No days means only for this browser session
WebUtil.createCookie = function(name,value,days) { WebUtil.createCookie = function(name,value,days) {
var date, expires; var date, expires, secure;
if (days) { if (days) {
date = new Date(); date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000)); date.setTime(date.getTime()+(days*24*60*60*1000));
expires = "; expires="+date.toGMTString(); expires = "; expires="+date.toGMTString();
} } else {
else {
expires = ""; expires = "";
} }
document.cookie = name+"="+value+expires+"; path=/"; if (document.location.protocol === "https:") {
secure = "; secure";
} else {
secure = "";
}
document.cookie = name+"="+value+expires+"; path=/"+secure;
}; };
WebUtil.readCookie = function(name, defaultValue) { WebUtil.readCookie = function(name, defaultValue) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment