Sharing sessions between Laravel project and other projects

Source: Internet
Author: User
The sharing session between Laravel project and other projects is summarized here. some people may need it later,
In fact, Laravel's session is not a session manager that comes with PHP. Instead, we fully implement one by ourselves.
Note that it is completely self-implemented. it is not a session processor defined by session_set_save_handler in the traditional sense.

So it's easy to solve the problem of sharing sessions with another ThinkPHP Project ~
Start the session that comes with PHP in Laravel, that is, session_start.

This is their code comment "Note that the Laravel sessions do not make use of PHP" native "sessions in any way since they are crappy ."
Remember that Laravel does not use a PHP "native" session anywhere, because it is very poor.

Okay, now I only need to start a bad session.

By kankana

The preceding figure shows how to access sessions of other programs from laravel.

The following describes how to access laravel's session (file) from outside ).

When laravel's session driver is set to file, these session files are stored in app/storage/sessions in json format.

The key is how to find the corresponding session file?

This file name is encrypted and stored in the laravel_session of the cookie.

How can I decrypt laravel_session to obtain the file name?

1. first install this library:

Https://github.com/illuminate/encryption

2. get the encryption key

Key in app/config/app. php

3,

$ Encrypter = new Illuminate \ Encryption \ Encrypter ($ key );
$ Session_filename = $ encrypter-> decrypt ($ _ COOKIE ['laravel _ session']);

This is roughly the case.


======================================

==========================================

The best practice for Session sharing between projects is to store Session information in Redis or databases, for example, only Redis or database can be read.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.