Using Laravel Session Database

I am trying to save the details of each session of people in a database as shown below: http://laravel.com/docs/4.2/session#database-sessions and now I have my table migrated and looking good. However, I cannot find any docs to help you use this table. I want to track the latest activities of each person and also count people online.

Can I provide examples of using the session database or links to documentation? I assumed this table would be auto-managed by Laravel, but it seems that I am wrong.

+3


source to share


1 answer


Can I provide examples of using the session database or links to documentation? I assumed this table would be auto-managed by Laravel, but it seems that I am wrong.

The only thing wrong is your assumption that you are wrong. The session database is the storage engine for the Laravel session system. After setting up the database and configuring Laravel to use the session database, you can use the syntax in the session documents to save and retrieve data that is associated with each individual user of your web system.

So there you have step 1 - your database table is created.

Step 2: configuring the storage engine by editing

app/config/session.php

      



and changing this

'driver' => 'file',

      

in that

'driver' => 'database'

      

Once you have done this, any call to the session method put

(or other persistence methods) will store the data in this table.

+4


source







All Articles