get session storage php

48

// Save data to sessionStorage
sessionStorage.setItem('key', 'value');

// Get saved data from sessionStorage
let data = sessionStorage.getItem('key');

// Remove saved data from sessionStorage
sessionStorage.removeItem('key');

// Remove all saved data from sessionStorage
sessionStorage.clear();
<?php
  session_start();  
  if(isset($_SESSION['views']))
      $_SESSION['views'] = $_SESSION['views']+ 1;
  else
      $_SESSION['views'] = 1;

  echo "views = " . $_SESSION['views']; 
?>
if(sessionStorage.getItem("data")){
//do some thing..
}else{
alert("the data isn't set.");
}

Comments

Submit
0 Comments