Created
June 24, 2025 01:47
-
-
Save JezDriver/30e69de0bcefe948735e4d16d22fa965 to your computer and use it in GitHub Desktop.
Check if a session exists and a variable has been set #php
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
| <? | |
| function isNewSession() { | |
| if(session_id() == '' || !isset($_SESSION) || session_status() === PHP_SESSION_NONE) { | |
| // session isn't started | |
| session_set_cookie_params(3600,"/"); // 1 hour | |
| session_start(); | |
| } | |
| if (!isset($_SESSION['new_session'])) { | |
| $_SESSION['new_session'] = true; | |
| } | |
| else { | |
| $_SESSION['new_session'] = false; | |
| } | |
| return $_SESSION['new_session']; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment