Register Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools
  #1  
Old 01 Feb 2009, 16:52
davide101 davide101 is offline
 
Join Date: Dec 2005
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.
__________________
David Edelman
Diabetes Forum
Reply With Quote
  #2  
Old 03 Feb 2009, 06:43
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Real name: Hanson
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).
__________________
Former vBulletin.org Staff Member

View My Modifications
29 Releases and Counting... Latest Modification: dmActivityStream - vBookie Integration (4.x)

Please do not PM me to ask for support - please use the relevant thread or forum.
Reply With Quote
  #3  
Old 03 Feb 2009, 16:53
davide101 davide101 is offline
 
Join Date: Dec 2005
Dismounted, thank you! I searched for more info and came across a very useful example that's also by you: http://www.vbulletin.org/forum/showp...39&postcount=4

--------------- Added 03 Feb 2009 at 17:04 ---------------

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:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Now if $firstvisit is true, I can call different code in my templates.
__________________
David Edelman
Diabetes Forum

Last edited by davide101; 03 Feb 2009 at 17:04. Reason: Auto-Merged DoublePost
Reply With Quote
  #4  
Old 04 Feb 2009, 07:14
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Real name: Hanson
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".
__________________
Former vBulletin.org Staff Member

View My Modifications
29 Releases and Counting... Latest Modification: dmActivityStream - vBookie Integration (4.x)

Please do not PM me to ask for support - please use the relevant thread or forum.
Reply With Quote
Reply

Similar Threads
Thread Thread Starter Forum Replies Last Post
Administrative and Maintenance Tools External Data Provider Usergroup/Cookie Setting Abe1 vBulletin 3.6 Add-ons 76 28 Feb 2015 00:28



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


New To Site? Need Help?

All times are GMT. The time now is 07:02.

Layout Options | Width: Wide Color: