Show all current sessions
This code shows all session variables that are active.
1 2 3 4 5 6 7 8 |
<?php session_start(); foreach ($_SESSION as $key=>$val){ echo $key." ".$val; } ?> |
You just have to set each page with a session as the name of the page and with a time, the this will show/track how many people are viewing what page via the admin-logs page, it will search and show info put out by the […]
Set session variable and check if equal to value
Set session variable to yesok
1 2 3 4 5 6 7 |
<?php session_start(); // store session data $_SESSION["drax"] = "yesok"; ?> |
Check it on next page
1 2 3 4 5 6 7 8 9 10 11 12 |
<?php session_start(); if($_SESSION['drax'] == 'yesok') { // your variable equals 'yes' do something } if($_SESSION['drax'] != 'yesok') { // your variable does not equal 'yes' do something } ?> |
Else do a redirect and add this to the top
1 2 3 4 5 6 7 8 9 |
<?php if($_SESSION['drax']!= 'yes'){ header("Location: index.php"); } else { header("Location: xxx.php"); } ?> |