Home  >  Q&A  >  body text

Thinkphp5.1 encountered session problems when learning

Does anyone know that after I added session:set() to the controller, the method failed and no error was reported? Please help me find out why. I used phpstudy to deploy the apache server!

The code is as follows:

<?phpnamespace app\index\controller;
use app\index\controller\Base;use think\Request;

use app\index\model\User as UserModel;

use think\Session;
class User extends Base{
// Login page

function login() %

清风新影清风新影1779 days ago1455

reply all(5)I'll reply

  • lk

    lk2020-01-15 18:39:55

    Hahaha, static references need to use think/faced/session

    reply
    0
  • 有什么是忘不了的。

    有什么是忘不了的。2020-01-07 19:34:31

    I think it's your session::set('user_info', $user->getdata()); that is wrong. The getdata in $user->getdata() should be getData

    image.png

    reply
    0
  • 刀刀

    刀刀2020-01-02 10:05:31

    Have you solved it?

    I have the same problem

    reply
    0
  • ringa_lee

    ringa_lee2020-01-01 14:11:02

    Is session enabled in your configuration?

    reply
    0
  • 清风新影

    Open session.PHP in the config directory, session.auto_start=1 in php.ini

    清风新影 · 2020-01-01 18:07:01
  • Cancelreply