如果尝试以不同用户身份登录,则自动注销当前会话 [英] Auto logout current session if trying to login as different user

查看:105
本文介绍了如果尝试以不同用户身份登录,则自动注销当前会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,



只是一个简单的问题:



我想创建一个if语句当我在登录表单中输入详细信息后点击登录时会自动销毁当前会话。我还希望在旧会话被销毁时创建新会话,这意味着第一个会话的用户名更改为新会话用户名。



伪代码:



Hi there,

Just a quick question:

I want to create an if statement that automatically destroy the current session when somebody click 'Log in' after entering their details in my login form. I would also like the new session to be created as the old session is destroyed, meaning the first session's username changes to the new sessions username.

Pseudo Code:

// if session exists (if a user is logged in) when clicking 'Log in' after entering different username/password
{
//destroy sessions and create new session with the details submitted
}
else
{
//session doesnt exist, so log in the user (meaning the destroy session isnt needed)
}





这是随后的代码,代码用于从详细信息开始会话(使用POST从表单存储为变量)。





This is the code that will follow, the code is used to start a session from details (stored as variables) from a form using POST.

$username = strtolower($_POST['username']);
$password = strtolower($_POST['password']);

if ($username&&$password)
{//starts validation and session start functionality





谢谢!



Thanks!

推荐答案

用户名 = strtolower(
username = strtolower(


_POST ['' 用户名']);
_POST['username']);


密码 = strtolower(
password = strtolower(


这篇关于如果尝试以不同用户身份登录,则自动注销当前会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆