vendredi 14 octobre 2016

Getting session values from database in laravel 5

Here is my code

class CreateSessionsTable extends Migration
{
public function up()
    {
        Schema::create('sessions', function (Blueprint $table) {
            $table->string('id')->unique();
            $table->text('payload');
            $table->integer('last_activity');
        });
    }
    public function down()
    {
        Schema::drop('sessions');
    }
}

In config/session.php file changed 'driver' => env('SESSION_DRIVER', 'database'), In DB table was created. When user login i used below code to push values into session

Session::put('userid', $userid);
Session::put('useremail', $useremail);

Then another method i checked session

$data = Session::all();
        var_dump($data);

Its returning like this,

array (size=3)
  '_token' => string 'kD3zC2YF4v63RF1EkAVe0YoM4zLj9kGtiV4vpEzG' (length=40)
  '_previous' => 
    array (size=1)
      'url' => string 'http://localhost/Login' (length=28)
  'flash' => 
    array (size=2)
      'old' => 
...

So how to get that user values from db.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire