Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maybe possible to use php sessions? #4

Open
kalenderfamily opened this issue Feb 2, 2022 · 1 comment
Open

Maybe possible to use php sessions? #4

kalenderfamily opened this issue Feb 2, 2022 · 1 comment

Comments

@kalenderfamily
Copy link
Contributor

kalenderfamily commented Feb 2, 2022

Found this:

<?php
session_set_cookie_params(10800);
session_start();
?>
<?php
$counterstand = intval(file_get_contents("counter.txt"));
 
if(!isset($_SESSION['counter_ip']))
   {
   $counterstand++;
   file_put_contents("counter.txt", $counterstand);
 
   $_SESSION['counter_ip'] = true;
   }
 
echo $counterstand;
?>

Source: https://www.php-einfach.de/experte/php-codebeispiele/besucherzaehler-mit-reload-sperre/

@kalenderfamily
Copy link
Contributor Author

kalenderfamily commented Feb 2, 2022

Really easy to integrate into theme by including session_set_cookie_params(10800); to index.php and

$counterstand = intval(file_get_contents(dirname(__FILE__).'/'.'counter.txt'));
 
if(!isset($_SESSION['counter_ip']))
   {
   $counterstand++;
   file_put_contents(dirname(__FILE__).'/'.'counter.txt', $counterstand);
 
   $_SESSION['counter_ip'] = true;
   }
// echo dirname(__FILE__).'/'.'counter.txt';

echo 'Total hits: '.$counterstand;

to the theme.

or just counter.txt then counter file will be in Pluck's root

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant