WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Index
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
Mobile Dev World

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : Encrypted Sessions
Categories : PHP, PHP Classes, Sessions Click here to Update Your Picture
Shashank Prabhakara
Date : Aug 31st 2008
Grade : 5 of 5 (graded 1 times)
Viewed : 2217
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Shashank Prabhakara
Action : Grade This Code Example
Tools : My Examples List

 
Like this code?
Show the author your appreciation.
Submit your own code examples 
 

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');
       
}
       
}

?>



A beginner's session handling class
Categories : PHP, PHP Classes, Sessions, Beginner Guides
Optimized Online users class
Categories : PHP, PHP Classes, Sessions
base64 with encryption - encode and decode sessions
Categories : PHP, PHP Classes, Encryption, Sessions
SPL and ITERATOR : examples
Categories : PHP, Object Oriented, PHP Classes, Sessions
Password reminder
Categories : PHP, PHP Classes, Databases, MySQL, Mail
Form Elements Class
Categories : PHP, PHP Classes, Form Processing
Filter - A simple class that lets you use multiple functions to create custom filters.
Categories : PHP, PHP Classes, Strings
DbObject - A PHP wrapper for working with various databases
Categories : Databases, PHP, PHP Classes
Simple class that uses GD to draw pie charts. After the class definition there's some sample code to demonstrate how you use the class.
Categories : Graphics, PHP, PHP Classes, GD image library, Charts and Graphs
Browser Detecor Class
Categories : PHP Classes, PHP, HTML
CSS style switcher
Categories : PHP, CSS, HTML and PHP, Arrays, Sessions
Bs_IniHandler is a class that can read and write ini-style files (and strings)
Categories : PHP, Filesystem, PHP Classes
Specify your connection settings and create a link to a MySQL database.
Categories : PHP, PHP Classes, Databases, MySQL, Beginner Guides
Warning: Unknown(): A session is active. You cannot change the session module's ini settings at this time. in Unknown on line 0
Categories : PHP, Sessions, Databases, MySQL
PHP Zip Utility
Categories : PHP, PHP Classes, Compression