dimanche 27 décembre 2015

Laravel 5 Session working in Postman not working if called from browser

After login I use session to set the user details. If i use postman i can get the session details. If i try logging from my browser its showing null

Here is my controller

namespace App\Http\Controllers;
use App\Models\User;
use Session;

class UserController extends Controller {

  public function login(){
    $postdata = file_get_contents("php://input");
    $request = json_decode($postdata);
    $requestArray = array();
    foreach($request as $key => $value){
      $requestArray[$key] = $value;
    }
    $user = User::login($requestArray);
    Session::put("activeuser", $user);
    Session::save();
    return json_encode(array('result'=>Session::get("activeuser")));

  }

Controller to fetch session details

namespace App\Http\Controllers;
use Session;


class ThisSessionController extends Controller {

  public function getdetails($key)
  {

        return json_encode(array($key => Session::get($key)));

  }

}

config/session.php

        'driver' =>  'file',



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire