php - Laravel Global Storage -


i want store result of query in session (or global) variable, can retrieve variable different controller or action in laravel 5.1. i'll take time explain further, what's happening here getting data form, , after have more data different page , perform db transaction then. earlier used zend framework in had storage object in 1 store data in format. here code snippet.

<?php namespace app\http\controllers; use illuminate\http\request;   use illuminate\support\facades\session; use app\http\requests;  use app\http\controllers\controller; use db; use auth; use illuminate\curl\curlrequesthandler; use config; class mycontroller extends controller {   public function myajax(request $request) {     $data = "some data db operation";   session::put('myformdata', $data2);        $value = session::get('myformdata');         print_r($value); //works fine }  public function someotherfunction(request $request){        $val = session::get('myformdata');        print_r($val);die('check');     // no data ! }  

how data? guess every time hits new action, session value restored default. there other way so?

resolved issue using session instance via http request. $request->session()->put('test', $curlresponse); // inside myajax function. $value = $request->session()->get('test', 'default'); //in //someotherfunction


Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -