Session encryption issues

Hi All,

I am banging my head on a session encryption issue and wondered if anyone has ideas which will help. Following is my current configuration:
OS = Windows XP Pro SP2
PhP Version: 5.2.5
Web Server: Apache HTTP Server 2.0.59

The error I am getting: Fatal error: Call to undefined function mcrypt_create_iv() in C:websHHCincludessession.php on line 8

The code:

[code]<?php
ini_set(‘error_reporting’, E_ALL);
//die(“test”);
session_start( );

$cfg[‘session_key’] = ‘01234567890123456789012345678901’;

$cfg[‘session_iv’] = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_DEV_URANDOM);
//echo($cfg);

function session_handler( ) {

global $cfg;

session_get( );

if( ( !session_is_registered( “auth_code” ) ) || ( $_SESSION[‘auth_code’] != $_SERVER[‘REMOTE_ADDR’] ) ) {
header( ‘Location: /’ ); /* Redirect browser /
exit; /
Make sure that code below does not get executed when we redirect. */
}
}

function session_get( ) {

global $cfg;

$crypttext = base64_decode( $_COOKIE[‘DATA’] );
$string = mcrypt_decrypt( MCRYPT_RIJNDAEL_256, $cfg[‘session_key’], $crypttext, MCRYPT_MODE_ECB, $cfg[‘session_iv’] );
session_decode( $string );
}

function session_put( ) {

global $cfg;

$string = session_encode( );
$crypttext = mcrypt_encrypt( MCRYPT_RIJNDAEL_256, $cfg[‘session_key’], $string, MCRYPT_MODE_ECB, $cfg[‘session_iv’] );
setcookie( “DATA”, base64_encode( $crypttext ), 0, “/”, “.localhost” );
}

?>[/code]

This code was originally written in a php 4 version and that may be my issue but if so I am at a loss for solving it. Any help would be greatly appreciated!

See the requirements section on this page and make sure you meet all of them. Separate libraries are required for mcrypt functions, and you may have had them installed on your PHP4 installation, but not on your current setup.

Are you aware of the correct libraries that I need in order to make mcrypt work with php 5?

Sponsor our Newsletter | Privacy Policy | Terms of Service