Category: >> PHP Code >> Encrypted Sessions Bookmark and Share

<< lastnext >>

Snippet Name: Encrypted Sessions

Description: A simple class used to encode and decode session values to make it harder to obtain private session values for people with access to session data.

It uses base64 encoding and mcrypt_encrypt encryption to set the values of one or more session variables values.

The class may also retrieve the value of an encoded session variable and decode it.

Also see:
» Easy Password Encryption and Decry...
» Check if current session is using ...
» Simple reversible encryption
» Reversible Encryption in PHP
» TIMESTAMP: SessionTimeZone
» Kill Session
» DBA Sessions

Comment: (none)

Author: CoderZone
Language: PHP
Highlight Mode: PHP
Last Modified: December 02nd, 2010

// base64 encode and decode sessions 
class encrypt_session{ 
var $enc_val;
var $dec_val;
function encode($set_ses){ 
	foreach($set_ses as $key=>$value){
  $_SESSION[$key] = base64_encode($value);
  // set encoded var to display 
  $this->$enc_val.=$key = base64_encode($value).'<br>';
function decode($get_ses){ 
   $dec_ses = $_SESSION[$get_ses];
    // set decoded var to display 
    $this->$dec_val= base64_decode($dec_ses);
There haven't been any comments added for this snippet yet. You may add one if you like.  Add a comment 
© | users online: 8