Created
August 22, 2013 10:35
-
-
Save tournasdim/6305686 to your computer and use it in GitHub Desktop.
L4 Session signature (list of most used Session methods)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
Illuminate\Session\SessionServiceProvider --> Illuminate\Session\SessionManager --> | |
-----> Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage | |
Session::put('key', 'value'); // Storing An Item In The Session | |
Session::push('user.teams', 'developers'); // Push A Value Onto An Array Session Value | |
$value = Session::get('key'); // Retrieving An Item From The Session | |
$value = Session::get('key', 'default'); // Retrieving An Item Or Returning A Default Value | |
$value = Session::get('key', function() { return 'default'; }); // Retrieving An Item Or Returning A Default Value using a callback | |
$data = Session::all(); // Retrieving All Data From The Session | |
if (Session::has('users')) { //} ; // Determining If An Item Exists In The Session | |
Session::forget('key'); // Removing An Item From The Session | |
Session::flush(); // Removing All Items From The Session | |
Session::regenerate(); // Regenerating The Session ID | |
Session::flash('key', 'value'); // store items in the session only for the next request. | |
Session::reflash(); // Reflashing The Current Flash Data For Another Request | |
Session::keep(array('username', 'email')); // Reflashing Only A Subset Of Flash Data | |
// When using the database session driver, you will need to setup a table to contain the session items | |
Schema::create('sessions', function($table) { | |
$table->string('id')->unique(); | |
$table->text('payload'); | |
$table->integer('last_activity'); | |
}); | |
// List of Session Drivers | |
native - sessions will be handled by internal PHP session facilities. | |
cookie - sessions will be stored in secure, encrypted cookies. | |
database - sessions will be stored in a database used by your application. | |
memcached / redis - sessions will be stored in one of these fast, cached based stores. | |
array - sessions will be stored in a simple PHP array and will not be persisted across requests. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment