我使用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"
]
}
}
您正在寻找Android和iOS的原生onDestroy
和applicationWillTerminate
函数。尝试通过添加这些关键字来搜索插件。这些事件似乎存在一些cordova插件:
但是,我没有检查它们的有效性。当您的WebView
应用程序通过cordova桥接收事件时,应用程序可能实际上已经被破坏了。
另外请注意,为什么不在会话中坚持会话令牌呢?只需将其妥善存放在某处。每次关闭应用程序时用户无需登录这一事实是一个很好的功能,而不是错误。