This is an outdated version of PHPasap. Please visit for the latest version.


PHPasap provides the Session library to handle native session. By default sessions are already started. So you don't have to do a session_start()

Set new or update existing session variable

Instead of using the global $_SESSION directly you are better off with below code

Session::set("name", "value");
Session::set("name", ["value_1","value_2"]);

Get session variable value

Similarly for getting a session variable value you can use below code

$value = Session::get("name");
//returns null if "name" wasn't set

If given session variable not found then get() returns null.

Flashing data

Flashing a session means the session variable will be available only for next request. This is particularly useful for showing form validation error.

Session::flash("error", "Username/Password incorrect");

Retrieving the flash data

Getting the flash data is same as getting any other session variable

$error = Session::get("error");