The use of Cookies

Talk about writing modules and plugins for CMS Made Simple, or about specific core functionality. This board is for PHP programmers that are contributing to CMSMS not for site developers
Post Reply
musicscore
Power Poster
Power Poster
Posts: 489
Joined: Wed Jan 25, 2006 11:53 am

The use of Cookies

Post by musicscore »

Hey There Again.

I'm building a module and I want that module to know when an user visited a page.
When he visited the page less then x hours ago, an php action is skipt.

So I was thinking of two solutions :
  • Using a cookie - Set a cookie with a date value and exparation periode and check the date value (this is the easy way)
  • Register the user in a database with ip-address and timestamp. (A lot of programming)
I was thinking about using the cookie methode but sometimes coockies are blocked by the browser of the user.

What do you think is the best way to check to time an user was visiting a page.
Please your advise.
User avatar
DIGI3
Dev Team Member
Dev Team Member
Posts: 1795
Joined: Wed Feb 25, 2009 4:25 am

Re: The use of Cookies

Post by DIGI3 »

Typically you'd use session variables for this. I don't have specific recommendations as I'm not a module developer, but hopefully that points you in the right direction.
Not getting the answer you need? CMSMS support options
musicscore
Power Poster
Power Poster
Posts: 489
Joined: Wed Jan 25, 2006 11:53 am

Re: The use of Cookies

Post by musicscore »

Thanks Digi3

Session variables only resist as long as the visitor keeps his browser open. When he closes his browser, start it again and opens the website again, the module will not know when that user/ip-address was here before. So I need to use Cookies or a database entry.

That is why I think Session Variables will not work.

(Ps. I am also not a developer (yet) but trying to make a nice module and learn, learn and learn)
User avatar
DIGI3
Dev Team Member
Dev Team Member
Posts: 1795
Joined: Wed Feb 25, 2009 4:25 am

Re: The use of Cookies

Post by DIGI3 »

Cookies are probably best in that case then. If you follow guidelines for the target audience, and don't store any personal information, most people will consent. If they do not consent or have cookies disabled, they are generally aware they will lose some functionality.
Not getting the answer you need? CMSMS support options
Post Reply

Return to “Developers Discussion”