PHP simple session class code

高洛峰
Release: 2023-03-01 11:44:02
Original
1017 people have browsed it

The code is as follows:

=5 } public function set_true() { if( isset($_SESSION['user']) ) $_SESSION['user'] = 1 ; else $this->error(); } public function get_status() { return $_SESSION['user']; } public function end_session() { session_destroy(); } public function error() { } } ?>
Copy after login

Approximate usage
example:
log in page: $session = session::getObject();
$session->set_ture(); // if $row['password'] ==
next page:
Copy code The code is as follows:
$session = session::getObject();
if($session->get_status())
// .... the user is really
else
// . ...

log out: $session = session::getObject();
$session->end_session();
Return by get_status() whether the current user is logged in effectively

Related labels:
php
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
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!