I use a combined version:
if(session_id() == '' || !isset($_SESSION) || session_status() === PHP_SESSION_NONE) {
// session isn't started
session_start();
}
More Related Contents:
- PHP session lost after redirect
- PHP Sessions across sub domains
- PHP Session Fixation / Hijacking
- How to properly add cross-site request forgery (CSRF) token using PHP
- “Cannot send session cache limiter – headers already sent” [duplicate]
- How can I get an unknown username given an ID?
- How do PHP sessions work? (not “how are they used?”)
- Keeping session alive with Curl and PHP
- How unique is the php session id
- cleanup php session files
- Cookies vs. sessions
- PHP sessions that have already been started [duplicate]
- Session lost when switching from HTTP to HTTPS in PHP
- PHP – Session destroy after closing browser
- PHP Sessions with disabled cookies, does it work?
- Is this a proper way to destroy all session data in php?
- What is PHP session_start()
- PHP __PHP_Incomplete_Class Object with my $_SESSION data
- How do I continue a session from one page to another with PHP
- Remotely destroy a session in php (user logs in somewhere else)?
- Session hijacking and PHP
- Call to undefined function session_register() [duplicate]
- Why Session object destruction failed
- PHP Session not Saving
- Session lost after page redirect in php
- My Laravel 5.2.10 Sessions wont persist
- laravel – Can’t get session in controller constructor
- How do I save PHP session data to a database instead of in the file system?
- Issues with PHP 5.3 and sessions folder
- how to unset cookie in PHP?