I have two domain in same hosting one is using Custom PHP and another Laravel 5.4. I have set some value in session variable using custom PHP using $_SESSION. And Now after login its redirect to laravel .
Now my question is how can I get this Session variable inside laravel.
3 Answers
Laravel doesn't use native PHP sessions since Laravel 4.1.
We are no longer using Symfony's (and therefore PHP's) session handling facilities, and are using a custom solution that is simpler and easier to maintain
In Laravel you want to use Session:: facade or session() global helper to work with sessions:
// Saving value.
session()->put('key', 'value');
// Gettinng value.
session('key');
So you cannot access session data from another PHP application,
But you may be able to access the session from another Laravel app if you are using the same storage for session management for both apps (Redis, Memcached, shared session folder, ...) and you use the same APP_KEY (look in your .env file) and the same cookie identifier (look in your config\session.php file) in both apps.
6 Comments
you can use session() helper function. or Session Facade.
suppose you want to put something in session you can use
Session::put('key', 'this is something in session');
if you want to access the same
echo Session::get('key') //outputs this is something in session
1 Comment
You can access the Session facade by using the proper namespace \Session
1 Comment
@if(\Session::has('feedback')) do x, y, z. has() returns a bool value but you can use get() to access the actual value. edit: Nevermind just saw your new comment about using it on the back-end
$_SESSION[]eg: http://example.laravel/home?_token=somethingRandom, then you can use the token to retrieve the data from the database.https://yourdomain.com?myData