expiration (int): seconds after with the cookie automatically gets deleted
(self, key, value, expiration='Infinity', path='/', domain='', secure=False)
| 71 | """%{'sKey': key, 'sPath': path, 'sDomain': domain} ) |
| 72 | |
| 73 | def set_cookie(self, key, value, expiration='Infinity', path='/', domain='', secure=False): |
| 74 | """ |
| 75 | expiration (int): seconds after with the cookie automatically gets deleted |
| 76 | """ |
| 77 | |
| 78 | secure = 'true' if secure else 'false' |
| 79 | self.app_instance.execute_javascript(""" |
| 80 | var sKey = "%(sKey)s"; |
| 81 | var sValue = "%(sValue)s"; |
| 82 | var vEnd = eval("%(vEnd)s"); |
| 83 | var sPath = "%(sPath)s"; |
| 84 | var sDomain = "%(sDomain)s"; |
| 85 | var bSecure = %(bSecure)s; |
| 86 | if( (!sKey || /^(?:expires|max\-age|path|domain|secure)$/i.test(sKey)) == false ){ |
| 87 | var sExpires = ""; |
| 88 | if (vEnd) { |
| 89 | switch (vEnd.constructor) { |
| 90 | case Number: |
| 91 | sExpires = vEnd === Infinity ? "; expires=Fri, 31 Dec 9999 23:59:59 GMT" : "; max-age=" + vEnd; |
| 92 | break; |
| 93 | case String: |
| 94 | sExpires = "; expires=" + vEnd; |
| 95 | break; |
| 96 | case Date: |
| 97 | sExpires = "; expires=" + vEnd.toUTCString(); |
| 98 | break; |
| 99 | } |
| 100 | } |
| 101 | document.cookie = encodeURIComponent(sKey) + "=" + encodeURIComponent(sValue) + sExpires + (sDomain ? "; domain=" + sDomain : "") + (sPath ? "; path=" + sPath : "") + (bSecure ? "; secure" : ""); |
| 102 | } |
| 103 | """%{'sKey': key, 'sValue': value, 'vEnd': expiration, 'sPath': path, 'sDomain': domain, 'bSecure': secure}) |
| 104 | |
| 105 | |
| 106 | class LoginManager(gui.Tag, gui.EventSource): |
no test coverage detected