Created
October 13, 2015 13:37
-
-
Save YOzaz/6eee7035a0d83388320a to your computer and use it in GitHub Desktop.
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 namespace MyApp\Support\Memory; | |
| trait SessionManager | |
| { | |
| /** | |
| * Starts session if required | |
| * | |
| * @return void | |
| **/ | |
| protected function startSession() | |
| { | |
| if ( version_compare(PHP_VERSION, '5.4.0', '>=') ) | |
| { | |
| if (session_status() == PHP_SESSION_NONE) | |
| { | |
| @session_start(); | |
| } | |
| } | |
| else | |
| { | |
| if ( session_id() == '' ) | |
| { | |
| @session_start(); | |
| } | |
| } | |
| // compatibility with old PHP versions | |
| $_SESSION = isset($_SESSION) ? $_SESSION : []; | |
| $_SESSION = is_array($_SESSION) ? $_SESSION : [ $_SESSION ]; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment