Home > Backend Development > PHP Tutorial > PHP用户登录以后session和Cooike的有关问题

PHP用户登录以后session和Cooike的有关问题

WBOY
Release: 2016-06-13 13:16:06
Original
1032 people have browsed it

PHP用户登录以后session和Cooike的问题
现在我的程序是用户登录以后,把用户的登录信息写入session但是在同一台电脑上,另一个用户登录以后,就造成先前一个用户的session被覆盖或者是失效,浏览器是IE8,请问各位大神,这种问题该怎么处理呢,如果我改成把用户的登录信息写进Cooike会不会也出现后面的用户把先前用户的cooike覆盖掉呢?谢谢各位……

------解决方案--------------------
cookie只能存放单一字符,如字符串,session可以存放数组、对象等复杂数据,你可以用用户名(username)存放在一个数组中,如:arr=array();
arr[0]='zhangsan';
arr[1]='lisi';

$_SESSION[username]=arr;

每次需要显示用户时,$_SESSION[username][x]即可!

Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template