examples/webconsole/resources/js/jquery/jquery.dataTables.js
function _fnCreateCookie ( sName, sValue, iSecs, sBaseName, fnCallback )
		{
			var date = new Date();
			date.setTime( date.getTime()+(iSecs*1000) );
			
			/* 
			 * Shocking but true - it would appear IE has major issues with having the path not having
			 * a trailing slash on it. We need the cookie to be available based on the path, so we
			 * have to append the file name to the cookie name. Appalling. Thanks to vex for adding the
			 * patch to use at least some of the path
			 */
			var aParts = window.location.pathname.split('/');
			var sNameFile = sName + '_' + aParts.pop().replace(/[\/:]/g,"").toLowerCase();
			var sFullCookie, oData;
			
			if ( fnCallback !== null )
			{
				oData = (typeof $.parseJSON === 'function') ? 
					$.parseJSON( sValue ) : eval( '('+sValue+')' );
				sFullCookie = fnCallback( sNameFile, oData, date.toGMTString(),
					aParts.join('/')+"/" );
			}
			else
			{
				sFullCookie = sNameFile + "=" + encodeURIComponent(sValue) +
					"; expires=" + date.toGMTString() +"; path=" + aParts.join('/')+"/";
			}
			
			/* Are we going to go over the cookie limit of 4KiB? If so, try to delete a cookies
			 * belonging to DataTables. This is FAR from bullet proof
			 */
			var sOldName="", iOldTime=9999999999999;
			var iLength = _fnReadCookie( sNameFile )!==null ? document.cookie.length : 
				sFullCookie.length + document.cookie.length;
			
			if ( iLength+10 > 4096 ) /* Magic 10 for padding */
			{
				var aCookies =document.cookie.split(';');
				for ( var i=0, iLen=aCookies.length ; i<iLen ; i++ )
				{
					if ( aCookies[i].indexOf( sBaseName ) != -1 )
					{
						/* It's a DataTables cookie, so eval it and check the time stamp */
						var aSplitCookie = aCookies[i].split('=');
						try { oData = eval( '('+decodeURIComponent(aSplitCookie[1])+')' ); }
						catch( e ) { continue; }
						
						if ( oData.iCreate && oData.iCreate < iOldTime )
						{
							sOldName = aSplitCookie[0];
							iOldTime = oData.iCreate;
						}
					}
				}
				
				if ( sOldName !== "" )
				{
					document.cookie = sOldName+"=; expires=Thu, 01-Jan-1970 00:00:01 GMT; path="+
						aParts.join('/') + "/";
				}
			}
			
			document.cookie = sFullCookie;
		}
function _fnCreateCookie ( sName, sValue, iSecs, sBaseName, fnCallback )
		{
			var date = new Date();
			date.setTime( date.getTime()+(iSecs*1000) );
			
			/* 
			 * Shocking but true - it would appear IE has major issues with having the path not having
			 * a trailing slash on it. We need the cookie to be available based on the path, so we
			 * have to append the file name to the cookie name. Appalling. Thanks to vex for adding the
			 * patch to use at least some of the path
			 */
			var aParts = window.location.pathname.split('/');
			var sNameFile = sName + '_' + aParts.pop().replace(/[\/:]/g,"").toLowerCase();
			var sFullCookie, oData;
			
			if ( fnCallback !== null )
			{
				oData = (typeof $.parseJSON === 'function') ? 
					$.parseJSON( sValue ) : eval( '('+sValue+')' );
				sFullCookie = fnCallback( sNameFile, oData, date.toGMTString(),
					aParts.join('/')+"/" );
			}
			else
			{
				sFullCookie = sNameFile + "=" + encodeURIComponent(sValue) +
					"; expires=" + date.toGMTString() +"; path=" + aParts.join('/')+"/";
			}
			
			/* Are we going to go over the cookie limit of 4KiB? If so, try to delete a cookies
			 * belonging to DataTables. This is FAR from bullet proof
			 */
			var sOldName="", iOldTime=9999999999999;
			var iLength = _fnReadCookie( sNameFile )!==null ? document.cookie.length : 
				sFullCookie.length + document.cookie.length;
			
			if ( iLength+10 > 4096 ) /* Magic 10 for padding */
			{
				var aCookies =document.cookie.split(';');
				for ( var i=0, iLen=aCookies.length ; i<iLen ; i++ )
				{
					if ( aCookies[i].indexOf( sBaseName ) != -1 )
					{
						/* It's a DataTables cookie, so eval it and check the time stamp */
						var aSplitCookie = aCookies[i].split('=');
						try { oData = eval( '('+decodeURIComponent(aSplitCookie[1])+')' ); }
						catch( e ) { continue; }
						
						if ( oData.iCreate && oData.iCreate < iOldTime )
						{
							sOldName = aSplitCookie[0];
							iOldTime = oData.iCreate;
						}
					}
				}
				
				if ( sOldName !== "" )
				{
					document.cookie = sOldName+"=; expires=Thu, 01-Jan-1970 00:00:01 GMT; path="+
						aParts.join('/') + "/";
				}
			}
			
			document.cookie = sFullCookie;
		}
function _fnCreateCookie ( sName , sValue , iSecs , sBaseName , fnCallback ) { var date = new Date ( ) ; date . setTime ( date . getTime ( ) + ( iSecs * 1000 ) ) ; /* 
			 * Shocking but true - it would appear IE has major issues with having the path not having
			 * a trailing slash on it. We need the cookie to be available based on the path, so we
			 * have to append the file name to the cookie name. Appalling. Thanks to vex for adding the
			 * patch to use at least some of the path
			 */ var aParts = window . location . pathname . split ( '/' ) ; var sNameFile = sName + '_' + aParts . pop ( ) . replace ( / [\/:] / g , "" ) . toLowerCase ( ) ; var sFullCookie , oData ; if ( fnCallback !== null ) { oData = ( typeof $ . parseJSON === 'function' ) ? $ . parseJSON ( sValue ) : eval ( '(' + sValue + ')' ) ; sFullCookie = fnCallback ( sNameFile , oData , date . toGMTString ( ) , aParts . join ( '/' ) + "/" ) ; } else { sFullCookie = sNameFile + "=" + encodeURIComponent ( sValue ) + "; expires=" + date . toGMTString ( ) + "; path=" + aParts . join ( '/' ) + "/" ; } /* Are we going to go over the cookie limit of 4KiB? If so, try to delete a cookies
			 * belonging to DataTables. This is FAR from bullet proof
			 */ var sOldName = "" , iOldTime = 9999999999999 ; var iLength = _fnReadCookie ( sNameFile ) !== null ? document . cookie . length : sFullCookie . length + document . cookie . length ; if ( iLength + 10 > 4096 ) /* Magic 10 for padding */ { var aCookies = document . cookie . split ( ';' ) ; for ( var i = 0 , iLen = aCookies . length ; i < iLen ; i ++ ) { if ( aCookies [ i ] . indexOf ( sBaseName ) != - 1 ) { /* It's a DataTables cookie, so eval it and check the time stamp */ var aSplitCookie = aCookies [ i ] . split ( '=' ) ; try { oData = eval ( '(' + decodeURIComponent ( aSplitCookie [ 1 ] ) + ')' ) ; } catch ( e ) { continue ; } if ( oData . iCreate && oData . iCreate < iOldTime ) { sOldName = aSplitCookie [ 0 ] ; iOldTime = oData . iCreate ; } } } if ( sOldName !== "" ) { document . cookie = sOldName + "=; expires=Thu, 01-Jan-1970 00:00:01 GMT; path=" + aParts . join ( '/' ) + "/" ; } } document . cookie = sFullCookie ; }
Create a new cookie with a value to store the state of a table
@param {string} sName name of the cookie to create
@param {string} sValue the value the cookie should take
@param {int} iSecs duration of the cookie
@param {string} sBaseName sName is made up of the base + file name - this is the base
@param {function} fnCallback User definable function to modify the cookie
@memberof DataTable#oApi
Create a new cookie with a value to store the state of a table