Home » Php » unable to get session data from ajax request in laravel

unable to get session data from ajax request in laravel

Posted by: admin June 30, 2018 Leave a comment


i am having problem in session as i am new to laravel.
okay so, i am getting user location when user click on button Use my Current Location i get its location and sent this location via $.ajax request in jquery to laravel, here is my ajax request

                  method: "GET",
                  url: "{{ url('session_address') }}",
                  data: { location: userAddress }
                }).done(function( msg ) {
                    alert( "Ajax CallBack Data: " + msg );

Here is my route

Route::get('session_address','[email protected]');

and here is my controller

 public function SessionHandler(Request  $request)
    Session::put('key', $request->location);
    $value = Session::get('key');
    $sessiondata = Session::all();
    echo '<pre>'.$value; print_r($sessiondata);

i don’t know how to get ajax data that i sent. in chrome network tab i am getting true result of here is a result

http://localhost/mylarashop/session_address?location= here i get the current location which work fine 

in network tab in developer tool i am getting above url with true location and getting this error 500 (Internal Server Error)
i want to create a global session so that i use it in my whole laravel app.
Hope you understand my problem.