Grizzley g
New member
How do I define a variable in terms of another variable being true not using isset?
For instance, when echo $check. $check would echo yes if $var = 1 but $check would echo no if $var = 2. How would I go about that?
What I'm really trying to do is this:
<?php
session_start();
if(isset($_SESSION['views']))
{$_SESSION['views'] = $_SESSION['views']+1;}
else {$_SESSION['views'] = 1;}
echo "views = ". $_SESSION['views'];
$checksessionno = $_SESSION['views']=10;
if($_SESSION['views'] = 10) {
session_destroy();}
if (session_destroy()) {echo "Session destroyed!";}
?>
Meaning, how do I destroy the session when the counter hits session = 10?
When I run this code and refresh the page multiple times, some of the times it simply echoes me views = 1 and some other times shows me views = 11. I cannot get it to increase, but everytime I navigate to this page after closing the browser and reopening it, I get the "Session destroyed!" message when I load the page for the first time right next to the "views = 1" echo. So does it mean that the session ended even before it hit the 10 refresh limits?
For instance, when echo $check. $check would echo yes if $var = 1 but $check would echo no if $var = 2. How would I go about that?
What I'm really trying to do is this:
<?php
session_start();
if(isset($_SESSION['views']))
{$_SESSION['views'] = $_SESSION['views']+1;}
else {$_SESSION['views'] = 1;}
echo "views = ". $_SESSION['views'];
$checksessionno = $_SESSION['views']=10;
if($_SESSION['views'] = 10) {
session_destroy();}
if (session_destroy()) {echo "Session destroyed!";}
?>
Meaning, how do I destroy the session when the counter hits session = 10?
When I run this code and refresh the page multiple times, some of the times it simply echoes me views = 1 and some other times shows me views = 11. I cannot get it to increase, but everytime I navigate to this page after closing the browser and reopening it, I get the "Session destroyed!" message when I load the page for the first time right next to the "views = 1" echo. So does it mean that the session ended even before it hit the 10 refresh limits?