Results 1 to 1 of 1

Thread: Drop-in content box v2.0 Cookie Bug

  1. #1
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    29,027
    Thanks
    44
    Thanked 3,210 Times in 3,172 Posts
    Blog Entries
    12

    Default Drop-in content box v2.0 Cookie Bug

    1) Script Title: Drop-in content box v2.0

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici.../dropinbox.htm

    3) Describe problem: Session only cookie does not work in IE 8 and less. Here's an updated version of the script which corrects that:

    dropincontentbox.js

    Only the set cookie function is changed. It's changed to assure that one of the persistent modes is in play (day, hr or min) before attempting to calculate an expiration date:

    Code:
    dropincontentbox.routines={
    
    	cookiere: /^(\d+)(day|hr|min)$/, //re to parse duration if not 'session' -jds
    
    	getCookie:function(Name){ 
    		var re=new RegExp(Name+"=[^;]+", "i"); //construct RE to search for target name/value pair
    		if (document.cookie.match(re)) //if cookie found
    			return document.cookie.match(re)[0].split("=")[1] //return its value
    		return null
    	},
    
    	setCookie:function(name, value, duration){
    		var expirestr='', expiredate=new Date()
    		if (typeof duration!=="undefined" && (duration=dropincontentbox.routines.cookiere.exec(duration))){ //if set persistent cookie and not session -jds
    			var offsetmin=duration[1] * (duration[2]==='hr'? 60 : duration[2]==='day'? 60*24 : 1)
    			expiredate.setMinutes(expiredate.getMinutes() + offsetmin)
    			expirestr="; expires=" + expiredate.toUTCString()
    		}
    		document.cookie = name+"="+value+"; path=/"+expirestr
    	}
    }
    Last edited by jscheuer1; 06-08-2013 at 04:28 PM. Reason: detail
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Similar Threads

  1. Replies: 18
    Last Post: 11-07-2010, 02:16 PM
  2. Switch Content Script cookie
    By o.ash92 in forum Dynamic Drive scripts help
    Replies: 5
    Last Post: 12-10-2006, 06:02 AM
  3. Featured Content Slider Cookie
    By NSOrg in forum Dynamic Drive scripts help
    Replies: 2
    Last Post: 11-23-2006, 11:54 AM
  4. Adding a Cookie to Amazon Drop-In Script
    By five_texans in forum Dynamic Drive scripts help
    Replies: 1
    Last Post: 04-22-2006, 09:53 PM
  5. Switch Content Script Cookie being deleted
    By matg in forum Dynamic Drive scripts help
    Replies: 0
    Last Post: 07-18-2005, 10:30 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •