简体   繁体   中英

how to unset php session by using angular js

How to unset session in php, via angular js this is what i hve,

app.js

  $scope.ths=function () {
$http.get('ajax/logout.php', function (response) {
});
 //logout.php
session_start();
$_SESSION['user'] = "";

Use following to remove a variable from session

unset($_SESSION['user'])

if you want to logout completely you can also use Session Destroy method

PHP is a server side language while JavaScript and all its related frameworks built in JavaScript are client side, as Session are managed by Server so there is no direct connection between JavaScript and PHP to clear or manage your sessions however,

You can do a trick by creating a php file where you can unset all your session and call it asynchronously.

hope this will help.

Good luck.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM