summaryrefslogtreecommitdiff
path: root/web/src/containers/timezone/SelectTz.jsx
diff options
context:
space:
mode:
authorSorin Sbarnea <ssbarnea@redhat.com>2020-07-06 11:06:50 +0100
committerSorin Sbarnea <ssbarnea@redhat.com>2020-07-06 14:16:58 +0100
commit70a7997197bc61a0e8c24c107c9c73a990d5db53 (patch)
tree7be271de0533f4b3507c45e0b8944551ec596eb6 /web/src/containers/timezone/SelectTz.jsx
parent041e251b7c3d76f7cc89e491f2ed246b87b1cd9c (diff)
downloadzuul-70a7997197bc61a0e8c24c107c9c73a990d5db53.tar.gz
Replace cookie use with localStorage
Avoid use of cookies which are always sent to the server, so they are subject to privacy laws. Instead it makes use of browser local storage, something that is persistent and not exposed to the server side. Change-Id: I8be5c87267e366f0cf152145002c3d3f541add80
Diffstat (limited to 'web/src/containers/timezone/SelectTz.jsx')
-rw-r--r--web/src/containers/timezone/SelectTz.jsx23
1 files changed, 3 insertions, 20 deletions
diff --git a/web/src/containers/timezone/SelectTz.jsx b/web/src/containers/timezone/SelectTz.jsx
index 78092d2ab..b8e5060be 100644
--- a/web/src/containers/timezone/SelectTz.jsx
+++ b/web/src/containers/timezone/SelectTz.jsx
@@ -30,35 +30,18 @@ class SelectTz extends React.Component {
componentDidMount () {
this.loadState()
+ window.addEventListener('storage', this.loadState)
}
handleChange = (selectedTz) => {
const tz = selectedTz.value
- this.setCookie('zuul_tz_string', tz)
+ localStorage.setItem('zuul_tz_string', tz)
this.updateState(tz)
}
- setCookie (name, value) {
- document.cookie = name + '=' + value + '; path=/'
- }
-
loadState = () => {
- function readCookie (name, defaultValue) {
- let nameEQ = name + '='
- let ca = document.cookie.split(';')
- for (let i = 0; i < ca.length; i++) {
- let c = ca[i]
- while (c.charAt(0) === ' ') {
- c = c.substring(1, c.length)
- }
- if (c.indexOf(nameEQ) === 0) {
- return c.substring(nameEQ.length, c.length)
- }
- }
- return defaultValue
- }
- let tz = readCookie('zuul_tz_string', '')
+ let tz = localStorage.getItem('zuul_tz_string') || ''
if (tz) {
this.updateState(tz)
}