Title: Session variable not the same
Last modified: August 20, 2016

---

# Session variable not the same

 *  [kevindng](https://wordpress.org/support/users/kevindng/)
 * (@kevindng)
 * [13 years, 8 months ago](https://wordpress.org/support/topic/session-variable-not-the-same/)
 * 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.

## Tags

 * [session](https://wordpress.org/support/topic-tag/session/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [kevindng](https://wordpress.org/support/users/kevindng/)
 * Last activity: [13 years, 8 months ago](https://wordpress.org/support/topic/session-variable-not-the-same/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
