After logging out, it still says please do not log in again.
森
2017-10-26 12:58:29
0
8
1845

7_NBRTP{1$X_EO@O~TT241N.pngARHSAL0C9(EE~`EIK3`F.pngSE]EP2]LB1P5~_5RL~@IC56.pngWhy does the message "Please do not log in again" appear after I log out? The session is not cleared? Unscientific

Base.php controller:

<?php

namespace app\admin\common;

use think\Controller;

use think\Session;

class Base extends Controller{

// The Base.php controller mainly completes three tasks:

// 1. Create a login flag constant,

// 2. Process the unlogged,

// 3. Process the logged in,

protected function _initialize(){

parent::_initialize();

// In the initialization method of the public controller, create a constant to determine whether the user is logged in or logged in

define('USER_ID ',Session::get('user_id'));

}

// Determine whether the user is logged in, call

at the background entrance protected function isLogin(){

// If the login constant is empty, it means there is no login.

if(is_null('USER_ID')){

$this->error('Not logged in, none Access...','login/index');

}

}

// If the user is already logged in, he will no longer be logged in

protected function alreadyLogin(){

//If the login constant is empty, it means there is no login

if(!is_null('USER_ID')){

$this- >error('Please do not log in again...','index/index');

}

}

}



?>


森

reply all(3)
山外山

if(is_null('USER_ID')){

}

if(!is_null('USER_ID')){

}

Remove the two 'USER_ID' single quotes


路过

is_null is used to determine whether the variable is of type null

Just change it to empty()

  • reply Still not working
    author 2017-10-27 13:03:09
  • reply I followed it and it turned out to be correct. I can only say that this video is correct except that it does not say use think\Session;. Let’s learn together, I’m on WeChat emaoqingshan
    yestrue author 2017-10-31 23:19:06
  • reply You declared a constant and assigned a value, but the constant USER_ID was not processed when you exited.
    路过 author 2017-10-27 13:07:07
森

<?php


namespace app\admin\controller;


use app\admin\common \Base;

use think\Request;

use app\admin\model\Admin;

use think\Session;


class Login extends Base

{

// Render login interface

public function index()

{

$ This-& gt;

# Return $ this-& gt; view-& gt; fetch ('login');

##}


## // Verify user identity

public function check(Request $request)

{

//Set the initial value returned

$status=0;

                                                                          using using using ’           ’ ’ out ’ s ’ ’s ’ out out out ’s way out’s out’s’ out’s’ ’ through ’s ’ through ’ through ‐ through  ‐ ‐‐‐ ​ ​ ​ ​ ​ ​ ​=$data['username'];

            $password=md5($data['password']);

# $map=['username'=>$userName];

$admin=Admin::get($map);

// Separate username and password Verification

                                                                                                                                                                                                                                                                                                 ​else if($admin->password!=$password){

                  $message='Password is incorrect';

                          $message='Verification passed, please log in to the backend'; 'last_time'=>time()]);

                                                                                                                                      . name:'user_info',value:$data);

session::set('user_id',$userName);

session::set('user_info',$data);

}

return ['status'=>$status,'message'=>$message];

}

// Log out

public function logout()

{

// session(null);

Session::delete('user_id');

Session::delete('user_info');

$this->success('Registration successful, returning.. .','login/index');

//

}


## public function delete( $id)

{

//

}

}

##

  • reply Let’s learn together, I’m on WeChat emaoqingshan
    yestrue author 2017-10-31 23:19:22
  • reply Add use think\Session; in Base.php All places where Session is used must be added.
    阿拉坚果丶 author 2018-03-04 18:56:08
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template