In order to keep the sessions' values safe it's quite important to encrypt them... So I wrote this to encrypt and decrypt the session keys... siple as it is just pass the values to the functions and get the encrypted or decrypted value back. This method uses base64 encryption
<?php
$ky = '645735686'; // secret key for encrypt
class encode_session {
var $enc_val;
var $dec_val;
function encode($set_ses,$ky)
{
foreach($set_ses as $key=>$value){
$_SESSION[$key] = base64_encode(mcrypt_cbc(MCRYPT_BLOWFISH,$ky,$value,MCRYPT_ENCRYPT,'56546828'));
// set var to display or use
$this->$enc_val.=$key = $key.' = '.base64_encode($value).'<br>';
}
}
function decode($get_ses,$ky)
{
$dec_ses = base64_decode($_SESSION[$get_ses]);
// set var to display or use
$this->$dec_val= mcrypt_cbc(MCRYPT_BLOWFISH,$ky,$dec_ses,MCRYPT_DECRYPT,'56546828');