PDA

View Full Version : show text only once per day by vbulletin session or cookie


omardealo
07-10-2015, 04:05 PM
Hello ,

can i use vbulletin session or cookie to show text only once per day for users and visitors ?

THANKS :up:

kh99
07-11-2015, 10:28 AM
I suppose you could set a cookie to expire in 24 hours, then if someone doesn't have that cookie with a request, display the text and create the cookie.

Or you might be able to check whenever a session is created, and see if their last activity is more than one day ago, but I don't know the details of how to do that offhand. Well, I guess that's not quite right, since that way if they visited often they may never see the text. I guess you'd have to check for lastactivity being in the previous day or earlier.

omardealo
07-11-2015, 05:29 PM
thanks brother

I suppose you could set a cookie to expire in 24 hours, then if someone doesn't have that cookie with a request, display the text and create the cookie.

Is there a reference or a simple code to shows me the way



Or you might be able to check whenever a session is created, and see if their last activity is more than one day ago, but I don't know the details of how to do that offhand. Well, I guess that's not quite right, since that way if they visited often they may never see the text. I guess you'd have to check for lastactivity being in the previous day or earlier.

I thought the same idea , use of table session (lastactivity) but You are right .. if the member logine in per day will not see the code never

kh99
07-11-2015, 08:41 PM
There is a $vbulletin->session->created variable that's true when a session gets created, but I think it's kind of tricky to use, since sometimes the user gets redirected after the session is created and it won't be true anymore when you go to check it to display the text. I tried to write a plugin that checked that variable, and it never seemed to be true when logging in.

There's a vbulletin function vbsetcookie(), but it doesn't look like it allows setting of the expiration time, so I guess you'd have to use the php functions directly. I really don't know a lot about cookies so it's probably better if you research that if you want to go that route (unless of course someone else wants to provide the code).

You could also add a column to the user table and store the last time they saw the text, then you'd just have to check to see if it's today or not, and if not show the text and update the field.