Answers for "php check session variable"

PHP
3

create session in php

<?php 
  // Start the session
  session_start();

  // Set session variables
  $_SESSION["color"]= "blue";
  $_SESSION["animal"]= "dog";
  echo "The session variable are set up.";
?>
Posted by: Guest on June-16-2020
0

check session php

// For PHP versions > 5.4.0

if (session_status() === PHP_SESSION_NONE) {
    session_start();
}

// For PHP Versions < 5.4.0

if(session_id() == '') {
    session_start();
}
Posted by: Guest on March-09-2021

Browse Popular Code Answers by Language