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

  • SEARCH
  • Home
  • 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 9066475
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T16:44:28+00:00 2026-06-16T16:44:28+00:00

Im trying to add a captcha to my registration form. The image is rendering

  • 0

Im trying to add a captcha to my registration form. The image is rendering just fine except the session variable is always empty, so it doesn’t work at all..

I am using the following class : http://www.ejeliot.com/pages/php-captcha

According to the documentation i had to make a php file with the following content:

<?php
require('classes/PhpCaptcha.php');
$aFonts = array('fonts/VeraBd.ttf', 'fonts/VeraIt.ttf', 'fonts/Vera.ttf');
$oVisualCaptcha = new PhpCaptcha($aFonts, 200, 60);
$oVisualCaptcha->SetBackgroundImages('captchaimgbg.jpg');
$oVisualCaptcha->Create();
?>

And include this as an image.

Now ive looked into the Create(); function, and in this function another function named GenerateCode(); is called, which is responsible for generating the letters and putting it into a session variable.

The code is as follow:

      function GenerateCode() {
     // reset code
     $this->sCode = '';

     // loop through and generate the code letter by letter
     for ($i = 0; $i < $this->iNumChars; $i++) {
        if (count($this->aCharSet) > 0) {
           // select random character and add to code string
           $this->sCode .= $this->aCharSet[array_rand($this->aCharSet)];
        } else {
           // select random character and add to code string
           $this->sCode .= chr(rand(65, 90));
        }
     }

     // save code in session variable
     if ($this->bCaseInsensitive) {
        $_SESSION[CAPTCHA_SESSION_ID] = strtoupper($this->sCode);
     } else {
        $_SESSION[CAPTCHA_SESSION_ID] = $this->sCode;
     }
  }

The CAPTCHA_SESSION_ID is defined at the top of the class file.
In my index i have session_start(); , i double checked this and that is not the problem.

No matter what i try, $_SESSION is always empty, even if i add $_SESSION[‘bla’] = ‘bla’ manually in the create(); function, it doesn’t show up.

Does anyone have an idea what is causing this, or what i am doing wrong?

Thanks!

  • 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-06-16T16:44:29+00:00Added an answer on June 16, 2026 at 4:44 pm
    <?php
    
    session_start();
    require('classes/PhpCaptcha.php');
    $aFonts = array('fonts/VeraBd.ttf', 'fonts/VeraIt.ttf', 'fonts/Vera.ttf');
    $oVisualCaptcha = new PhpCaptcha($aFonts, 200, 60);
    $oVisualCaptcha->SetBackgroundImages('captchaimgbg.jpg');
    $oVisualCaptcha->Create();
    
    ?>
    

    You need to start the session with session_start() at the TOP of the code on all the pages that access/set $_SESSION variables.

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

Sidebar

Related Questions

I'm trying to add EWZRecaptcha to my registration form. My registration form builder looks
I'm trying to add a captcha to a site somebody else has made. I've
Trying to add a 'box' to a form at design time, I looked up
I am trying to add ReCaptcha into a mail form that I created which
I am trying to add a reCAPTCHA to my PHP contact form with AJAX.
I am trying add on dimension of an array together into a variable using
Trying to add django-registration to my app. I have installed setup tools to use
Trying to add Facebook login / registration to a site I'm working on. Been
im trying add item with ajax, all work, except the view doesnt refresh, when
I am new to CMS Made Simple and I am trying to add CAPTCHA

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.