@itutoring/itutoring_application_js_api 1.7.10 → 1.7.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CookiesManager.js CHANGED
@@ -9,9 +9,9 @@
9
9
 
10
10
  class CookiesManager
11
11
  {
12
- static SetCookie(name, value, expiracy)
12
+ static SetCookie(name, value, expiracy, force = false)
13
13
  {
14
- if (this.GetCookie(name) != null)
14
+ if (this.GetCookie(name) != null && !force)
15
15
  return;
16
16
 
17
17
  document.cookie = name + "=" + value + "; expires=" + expiracy + ";path=/";
@@ -38,6 +38,11 @@ class CookiesManager
38
38
 
39
39
  return null;
40
40
  }
41
+
42
+ static RemoveCookie(name)
43
+ {
44
+ document.cookie = name + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
45
+ }
41
46
  }
42
47
 
43
48
  export default CookiesManager;
package/apiController.js CHANGED
@@ -55,11 +55,23 @@ class APIController
55
55
 
56
56
  static async CreateVisitorSession()
57
57
  {
58
- const id = Date.now();
59
- const date = new Date();
60
- date.setTime(date.getTime() + (7 * 24 * 60 * 60 * 1000));
58
+ var id = '';
59
+ const urlParams = new URLSearchParams(window.location.search);
60
+ if (urlParams.has("vid"))
61
+ {
62
+ if (CookiesManager.GetCookie("session_url") != null)
63
+ CookiesManager.RemoveCookie("session_url");
61
64
 
62
- CookiesManager.SetCookie("session", id, date.toUTCString());
65
+ id = urlParams.get("vid");
66
+ CookiesManager.SetCookie("session_url", id, date.toUTCString());
67
+ }
68
+ else
69
+ {
70
+ id = Date.now();
71
+ const date = new Date();
72
+ date.setTime(date.getTime() + (7 * 24 * 60 * 60 * 1000));
73
+ CookiesManager.SetCookie("session", id, date.toUTCString());
74
+ }
63
75
  this.ReadUserSource();
64
76
 
65
77
  var rKey = await this.GetLocalRKey();
@@ -68,12 +80,9 @@ class APIController
68
80
 
69
81
  static GetVisitorSessionID()
70
82
  {
71
- const urlParams = new URLSearchParams(window.location.search);
72
- if (urlParams.has("vid")) {
73
- return urlParams.get("vid");
74
- }
75
-
76
83
  //console.log(CookiesManager.GetCookie("session"));
84
+ if (CookiesManager.GetCookie("session_url") != null)
85
+ return CookiesManager.GetCookie("session_url");
77
86
  return CookiesManager.GetCookie("session");
78
87
  }
79
88
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itutoring/itutoring_application_js_api",
3
- "version": "1.7.10",
3
+ "version": "1.7.12",
4
4
  "description": "Javascript API for iTutoring Application",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",