Auto increment a variable in session [closed]
How do I auto increment a value inside a session which will be used multiple times in a certain page.
$_SESSION['value']++
will do the trick, then output your variable on the page
<?php echo $_SESSION['value']; ?>
Something to consider is that $_SESSION['value'] should be set first, perhaps at the top of your page. You can add this if you wish to check:
<?php echo isset($_SESSION['value'])?$_SESSION['value']:''; ?>
精彩评论