• Hi all,
    I have a trouble when i implement simple captcha for my contact page.

    I created a plugin with two file content.

    In the_simple_captcha my code is:

    add_action('init','captcha_start',1);
    function captcha_start(){
        if(!session_id()){
            session_start();
        }
    }
    function the_simple_captcha(){
        $captcha = plugins_url('captcha.php',__FILE__);
        echo $_SESSION['captcha']; //test session
    ?>
        <img src="<?php echo $captcha ?>" alt="the simple captcha" />
    <?php
    }
    ?>

    and my captcha file

    <?php
        $string = substr(md5(rand(0,999)),10,6);
        $_SESSION['captcha'] = $string;
        $img=imagecreate(100,20);
        imagefill($img,0,0,imagecolorallocate($img,109,177,228));
        imagestring($img,5,20,3,$_SESSION['captcha'],imagecolorallocate($img,0,0,0));
        header("Content-type: image/png");
        imagepng($img);
        imagedestroy($img);
    ?>

    But $_SESSION[‘captcha’] not same image captcha.

  • The topic ‘Session variable not the same’ is closed to new replies.