Skip to content

Latest commit

 

History

History
25 lines (22 loc) · 525 Bytes

0501.md

File metadata and controls

25 lines (22 loc) · 525 Bytes

What is the output of this script the third time it is loaded in a browser by the same user?

session_start();
if (!array_key_exists('counter', $_SESSION)) {
    $_SESSION['counter'] = 0;
} else {
    $_SESSION['counter']++;
}
session_regenerate_id();
echo $_SESSION['counter'];
  • A) 2
  • B) 1
  • C) 3
  • D) 0
Answer

Answer: A