Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6805153
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:33:08+00:00 2026-05-26T19:33:08+00:00

I read a bit on how to secure a session and what I decided

  • 0

I read a bit on how to secure a session and what I decided to do was to save the session_id to the database, and then save it to a session variable after it has been encrypted.

Here is the class that I used for the encryption (it was writen by Orielly books author):

Encrypted class using session_set_save_handler

The I apply it this way:

ini_set('session.use_only_cookies',true);       

//calls the session class.  
 require_once(dirname(__file__)."/../../Administrator/secure_session.php");
             session_start();

            if( !isset($_SESSION['mod']) )          
            {   
                Moderator::insert_moderator($name,session_id());    

                $_SESSION['mod']= session_id();

                $_SESSION['time']=time();

                echo "<br/>Moderator session: ".$_SESSION['mod'];
            }

This is the exception which is being thrown:

Fatal error: Uncaught exception ‘Exception’ with message ‘I cannot generate a secure pseudo-random key. Please use PHP >= 5.3 or Mcrypt extension’ in C:\xampp\htdocs\PoliticalForum\Administrator\secure_session.php:74 Stack trace: #0 C:\xampp\htdocs\PoliticalForum\Administrator\secure_session.php(107): SecureSession->_randomKey(32) #1 [internal function]: SecureSession->open(‘C:\xampp\htdocs…’, ‘PHPSESSID’) #2 C:\xampp\htdocs\PoliticalForum\StoredProcedure\User\headerSite.php(43): session_start() #3 C:\xampp\htdocs\PoliticalForum\mainHome.php(14): include_once(‘C:\xampp\htdocs…’) #4 {main} thrown in C:\xampp\htdocs\PoliticalForum\Administrator\secure_session.php on line 74

What am I doing wrong, how can I fix this, cause I dont understand much of encryption!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T19:33:09+00:00Added an answer on May 26, 2026 at 7:33 pm

    The exception is because you’re probably using PHP < 5.3 or you didn’t include the mcrypt extension in your php.ini

    In your error log says line 74 of the class, if you look at it:

    (71)    if (defined(MCRYPT_DEV_URANDOM)) {
    (72)        return mcrypt_create_iv($length, MCRYPT_DEV_URANDOM);
    (73)    } else {
    (74)       throw new Exception("I cannot generate a secure pseudo-random key. Please use PHP >= 5.3 or Mcrypt extension");
    (75)    }
    

    that means that MCRYPT_DEV_URANDOM is not defined, and if you look in php.net you’ll see that it was introduced in PHP >= 5.3 on Widnows platforms


    To update you PHP download the latest stable version from here or here (Windows)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been trying to read a bit of the C++ standard to figure out
You can read about the 64-bit calling convention here . x64 functions are supposed
I've read a bit that putting a.NET 2.0 SQL CE database in the program
I'm trying to learn more about WPF and I've read a bit about Model-View-ViewModel
I need some help ... I'm a bit (read total) n00b when it comes
I want to come up with a language syntax. I have read a bit
I've read quite a bit of the Red Bean Software SVN Book, and some
I've read a little bit about unit testing and was wondering how YOU unit
I only read a little bit about this topic, but it seems that the
I'm trying to read a 16-bit greyscale TIFF file (BitsPerSample=16) using a small C

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.