search

Home  >  Q&A  >  body text

laravel5.2 session usage

Excuse me, how to store, get the value and clear the session in laravel5.2.
I followed the documentation, but after storing it in controller A, I could not get the value in controller B.

迷茫迷茫2804 days ago472

reply all(3)I'll reply

  • 迷茫

    迷茫2017-05-16 16:52:26

    // 存值
    $request->session->put(key,value);
    
    // 取值
    $request->session->get(key);
    
    // 清空
    $request->session->flush()

    You can read the documentation
    http://laravelacademy.org/post/3261.html

    reply
    0
  • 迷茫

    迷茫2017-05-16 16:52:26

    The laravel file is really too rough. The session is probably a trap for many people. If it is not a normal return control layer function, you need to call session()->save()

    reply
    0
  • 某草草

    某草草2017-05-16 16:52:26

    There are two main points to pay attention to when using session add, delete, modify and check:
    First, the session.php configuration is correct;
    Second, the add, delete, modify, and check functions are not written incorrectly.

    For the source code analysis of session, please see: Laravel Study Notes: Session Source Code Analysis (Part 1)

    reply
    0
  • Cancelreply