Make a counter table with a column count and update the first row of the
table each time there is an unique IP address every day...
Or you can implement other rule...
In your footer you will display the count
db.counter(1).count # You select row 1 content that is you count
You update your counter somewhere in a model, I would use db.py for that so
it will be execute each request :
db(db.counter.id == 1).update(count=db.counter(1).count+1)
db.commit() # Don't forget to commit!!
You can surround your update and commit with logic to just count users
access in different situation, as I say new IP address... You may require
to log IP address for this task...
If you want unique visitor log, there is other tool for the task, like
google analytic or if you want to stay with python and open source Piwik (
http://piwik.org/).
Richard
On Mon, Dec 1, 2014 at 12:30 PM, Gideon George
wrote:
> Please what I can do if I want to display the number of visits to each page
> of my site without restricting it to just individual sessions?
>
> Unlike the code below where it displays number of visits for a particular
> session, I want a situation where by I can put something like this at my
> footer. "Since December 1, this page has been viewed 12499 times". Please
> help me with the code if you can, I tried everything possible to no avail.
>
> def index():
> if not session.counter:
> session.counter = 1
> else:
> session.counter += 1
> return dict(message="Hello from MyApp", counter=session.counter)
>
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.