Table of Contents
回复讨论(解决方案)
Home Backend Development PHP Tutorial 求解,PHP实现单点登陆?

求解,PHP实现单点登陆?

Jun 23, 2016 pm 02:19 PM

现有一站点,要求会员实现单点登陆,就像QQ一样,同一个帐号只能登陆一次。
求高手指点,给个思路,要考虑到非正常退出(也就是直接X掉浏览器)的情况。


回复讨论(解决方案)

有人研究过这个问题,也就是跨session通信的问题。PHP不建议这样使用session,所以不让这么办,原因很多。
但是实现是不复杂的。用数据库配合来实现就是了。

也就是说通过判断session id

也就是说通过判断session id
望详解,说下步骤

做过类似的, 
用户登录的时候, 将当前IP放到数据库里面。

然后,用户每一步操作,都对比当前的IP和数据库里面的IP。 

如果不一样, 说明当前的这个用户已经在其他地方登录了。 

也就是不能同时有2个ID一样的用户用这个系统

使用nosql数据库,例如redis, set($user,$ip) 设置超时时间5分钟,每次访问页面如果ip一致刷新该数据。如果ip不一致,拒绝


也就是说通过判断session id
望详解,说下步骤
就是把4楼的ip改成session id
$ses_id = session_id(); 

根据用户id轮询查询数据库。

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to write an algorithm to find the least common multiple in Python? How to write an algorithm to find the least common multiple in Python? Sep 19, 2023 am 11:25 AM

How to write an algorithm to find the least common multiple in Python? The least common multiple is the smallest integer between two numbers that can divide the two numbers. In mathematics, solving the least common multiple is a basic mathematical task, and in computer programming, we can use Python to write an algorithm for solving the least common multiple. The following will introduce the basic least common multiple algorithm and give specific code examples. The mathematical definition of the least common multiple is: If a is divisible by n and b is divisible by n, then n is the least common multiple of a and b. To solve the minimum

How to use Python to implement the algorithm for solving factorial? How to use Python to implement the algorithm for solving factorial? Sep 19, 2023 am 10:30 AM

How to use Python to implement the algorithm for solving factorial? Factorial is an important concept in mathematics. It means that a number is multiplied by itself minus one, then multiplied by itself minus one, and so on until it is multiplied to 1. Factorial is usually represented by the symbol "!". For example, the factorial of 5 is expressed as 5!, and the calculation formula is: 5!=5×4×3×2×1=120. In Python, we can use loops to implement a simple factorial algorithm. A sample code is given below: deffacto

A quick way to calculate the inverse of a matrix - Numpy implementation A quick way to calculate the inverse of a matrix - Numpy implementation Jan 24, 2024 am 08:47 AM

Numpy is a well-known scientific computing library in Python, which provides rich functions and efficient computing methods for processing large multi-dimensional arrays and matrices. In the world of data science and machine learning, matrix inversion is a common task. In this article, I will introduce how to quickly solve the matrix inverse using the Numpy library and provide specific code examples. First, let's introduce the Numpy library into our Python environment by installing it. Numpy can be installed in the terminal using the following command: pipinsta

Using C language programming to solve the greatest common divisor Using C language programming to solve the greatest common divisor Feb 21, 2024 pm 07:30 PM

Title: Use C language programming to implement the greatest common divisor solution. The greatest common divisor (Greatest Common Divisor, GCD for short) refers to the largest positive integer that can divide two or more integers at the same time. Solving for the greatest common divisor can be very helpful for some algorithms and problem solving. In this article, the function of finding the greatest common divisor will be implemented through C language programming, and specific code examples will be provided. In C language, you can use the Euclidean Algorithm to solve the maximum

Learn how to find the greatest common divisor in C language Learn how to find the greatest common divisor in C language Feb 21, 2024 pm 11:18 PM

To learn how to find the greatest common divisor in C language, you need specific code examples. The greatest common divisor (Greatest Common Divisor, GCD for short) refers to the largest positive integer among two or more integers that can divide them. The greatest common denominator is often used in computer programming, especially when dealing with fractions, simplifying fractions, and solving problems such as the simplest ratio of integers. This article will introduce how to use C language to find the greatest common divisor and give specific code examples. There are many ways to solve the greatest common divisor, such as Euclidean

Writing a program to solve modular equations in C/C++? Writing a program to solve modular equations in C/C++? Sep 12, 2023 pm 02:21 PM

Here we will see an interesting problem related to modular equations. Let's say we have two values ​​A and B. We must find the number of possible values ​​that variable X can take such that (AmodX)=B holds. Suppose A is 26 and B is 2. So the preferred value of X would be {3,4,6,8,12,24}, hence the count of 6. This is the answer. Let's take a look at the algorithm to understand better. Algorithm possibleWayCount(a,b)−begin ifa=b,thenthereareinfinitesolutions ifa

C/C++ program to find the nth Fibonacci number? C/C++ program to find the nth Fibonacci number? Sep 12, 2023 pm 06:01 PM

The Fibonacci sequence is a sequence of numbers in which the next term is the sum of the previous two terms. The first two terms of the Fibonacci sequence are 0 followed by 1. In this problem, we will find the nth number in the Fibonacci sequence. To do this we will count all the numbers and print n items. Input:8Output:011235813 Description 0+1=11+1=21+2=32+3=5 Use a For loop to sum the first two items as the next item Example #include<iostream>usingnamespacestd;intmain(){ intt1= 0,t2=1,n,i,nextTerm;&am

How to solve for powers of 2 in PHP? How to solve for powers of 2 in PHP? Mar 28, 2024 am 11:09 AM

Title: How to solve for powers of 2 in PHP? Specific code examples are shared in PHP programming. Solving the power of numbers is a common requirement, especially in some algorithms and mathematical calculations. This article will discuss in detail how to solve the power of 2 in PHP and provide specific code examples for your reference. In PHP, you can use the exponentiation operator ** to calculate powers. For powers of 2, calculate $2^n$, where $n$ is the exponent of the power. Below we will implement this calculation in a few different ways. Method 1: Use ** luck

See all articles