The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Best practices for storing and using data in the vB cookie
I would like someone to point me to a simple tutorial on the right way to write and read data from a cookie (the vB one in this case) using php.
Here's my goal: the first time a member visits my site, I want to show an expanded 'reasons to join' guest box. On subsequent pageviews, I would like to show a much smaller version. I think the easiest way to do this is set a cookie when someone visits and only show the big box if the cookie isn't set. Can someone walk me through the 50,000ft view of how I should best go about this? I've never done anything with cookies and want to do this the right way in terms of coding standards and end-user speed. |
#2
|
||||
|
||||
Your friend is vbsetcookie(). When fetching the cookie, clean the cookie first using the vB Input Cleaner Class (and make sure you have added on the cookie prefix when fetching, this is not required when setting).
|
#3
|
|||
|
|||
Dismounted, thank you! I searched for more info and came across a very useful example that's also by you: https://vborg.vbsupport.ru/showpost....39&postcount=4
--------------- Added [DATE]1233680678[/DATE] at [TIME]1233680678[/TIME] --------------- For those of you that want a simple way to show something different to first time visitors, here's the plugin I'm using at Global Start: Code:
if (!isset($_COOKIE[COOKIE_PREFIX . 'FirstVisit'])) { // set variable for use in templates $firstVisit = true; // set cookie vbsetcookie('FirstVisit', '0', permanent); } |
#4
|
||||
|
||||
You do not need the third argument (it defaults to true). If you need to use it, you need to use "true" or "false", not "permanent".
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|