Wednesday, 22 August 2018

JS cookie handling

<script type='text/javascript'>
function setCookie(name,value,days) {
    var expires = "";
    if (days) {
        var date = new Date();
        date.setTime(date.getTime() + (days*24*60*60*1000));
        expires = "; expires=" + date.toUTCString();
    }
    document.cookie = name + "=" + (value || "")  + expires + "; path=/";
}
function getCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for(var i=0;i < ca.length;i++) {
        var c = ca[i];
        while (c.charAt(0)==' ') c = c.substring(1,c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
    }
    return false;
}
function eraseCookie(name) { 
    document.cookie = name+'=; Max-Age=-99999999;'; 
}
setCookie('TEST','Goal',7);
alert(getCookie('TEST'));
eraseCookie('TEST');
alert(getCookie('TEST'));
</script>

Wednesday, 25 July 2018

Cake php 64bit encrypt and decrypt

/*
 * Encrypt and base64 encode
 */
$encryptKey = "TESDEMO";
$secret = Security::cipher('1', $encryptKey);
$secret64Enc = base64_encode($secret);

// Decrypt your text
$secret64Dec = base64_decode($secret64Enc);
$nosecret = Security::cipher($secret64Dec,$encryptKey);
echo "$secret64Enc--------------$nosecret" ;
echo "<br>";

Friday, 8 June 2018

Import Large size of databse facing errors ERROR 1118 (42000) , ERROR 2006 (HY000) & ERROR 1118 (42000)

Your  path xampp\mysql\bin\my.ini 

# ERROR 2006 (HY000) at line 1995: MySQL server has gone away

max_allowed_packet = 256M

# ERROR 1118 (42000) at line 1995: The size of BLOB/TEXT data inserted in one transaction is greater than 10% of redo log size. Increase the redo log size using innodb_log_file_size.

innodb_log_file_size = 256M

# ERROR 1118 (42000) at line 1807: Row size too large (> 8126). Changing some columns to TEXT or BLOB or using ROW_FORMAT=DYNAMIC or ROW_FORMAT=COMPRESSED may help. In current row format, BLOB prefix of 768 bytes is stored inline

max_allowed_packet=1G
innodb_file_per_table=1
innodb_file_format=Barracuda

Once values changed restart you xampp & Mysql servers