我使用Cordova来构建在线应用程序,我在服务器(php)上使用了一些会话变量。当我退出此应用时,会话仍存在于我的服务器上。我如何解决它以自动取消所有会话? 这是我的package.json:
{
"name": "helloworld",
"displayName": "HelloCordova",
"version": "1.0.0",
"description": "A sample Apache Cordova application that responds to the deviceready event.",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Apache Cordova Team",
"license": "Apache-2.0",
"dependencies": {
"cordova-android": "^7.1.4",
"cordova-browser": "^5.0.4",
"cordova-plugin-device": "^2.0.2",
"cordova-plugin-dialogs": "^2.0.1",
"cordova-plugin-inappbrowser": "^3.0.0",
"cordova-plugin-nativestorage": "^2.3.2",
"cordova-plugin-network-information": "^2.0.1",
"cordova-plugin-share": "^0.1.3",
"cordova-plugin-statusbar": "^2.4.2",
"cordova-plugin-whitelist": "^1.3.3",
"cordova-plugin-x-toast": "^2.7.2"
},
"cordova": {
"plugins": {
"cordova-plugin-dialogs": {},
"cordova-plugin-nativestorage": {},
"cordova-plugin-device": {},
"cordova-plugin-whitelist": {},
"cordova-plugin-x-toast": {},
"cordova-plugin-statusbar": {},
"cordova-plugin-inappbrowser": {},
"cordova-plugin-network-information": {},
"nl.madebymark.share": {}
},
"platforms": [
"browser",
"android"
]
}
}
答案 0 :(得分:0)
您正在寻找分别用于Android和iOS的本机onDestroy
和applicationWillTerminate
函数。尝试通过添加这些关键字来搜索插件。似乎这些事件存在一些cordova插件:
但是,我还没有检查它们的有效性。您的WebView
应用程序通过cordova网桥收到事件时,该应用程序实际上很可能已经被破坏。
另一方面,为什么不将会话令牌也持久保存在您的应用中?只需将其安全地存储在某个地方即可。用户不必在每次关闭应用程序时都登录,这是一个很棒的功能,而不是一个错误。