php 中session的如何使用

WBOY
Release: 2016-06-13 11:15:59
Original
1097 people have browsed it

php 中session的怎么使用
初次做php项目,对于session的控制不太明白,看了一些资料还是比较迷茫,在这里希望各位大神们给解答一下,主要解决一下几个问题:
1、登录时,存储用户信息在session中
2、登录超时
3、对一些功能进行“是否登录”的验证

php??session php
------解决方案--------------------
在登录前使用session start就好
对功能模块查询session数组中的值然后就行判断
------解决方案--------------------
开启  session    

登陆后生成随机id  或者 将数据库中登陆id存入$nameid=session   

验证是否登陆,直接判断 $nameid  是否有值。
------解决方案--------------------
session_start();  
1、登录时,存储用户信息在session中
$_SESSION['user'] = 'xxx';
2、是否登录超时
if(isset($_SESSION['user']))
3、注销登录
unset($_SESSION);
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!