note 109675 added to features.sessions
| From: | billskipton at orange dot net | Date: | Wed, 08 Aug 2012 02:24:39 +0000 |
| Subject: | note 109675 added to features.sessions | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-189954@lists.php.net to get a copy of this message | ||
The note submitted by idandaniels is flawed in that the code to display the number of page views is
inside the 'else'.
The corrected code is...
<?php
session_start();
if(isset($_SESSION['views']))
{
$_SESSION['views']++;
}
else
{
$_SESSION['views']=1;
}
echo "Views=". $_SESSION['views'];
?>
----
Server IP: 69.147.83.197
Probable Submitter: 80.42.139.133
----
Manual Page -- http://www.php.net/manual/en/features.sessions.php
Edit -- https://master.php.net/note/edit/109675
Del: integrated -- https://master.php.net/note/delete/109675/integrated
Del: useless -- https://master.php.net/note/delete/109675/useless
Del: bad code -- https://master.php.net/note/delete/109675/bad+code
Del: spam -- https://master.php.net/note/delete/109675/spam
Del: non-english -- https://master.php.net/note/delete/109675/non-english
Del: in docs -- https://master.php.net/note/delete/109675/in+docs
Del: other reasons-- https://master.php.net/note/delete/109675
Reject -- https://master.php.net/note/reject/109675
Search -- https://master.php.net/manage/user-notes.php