Eggzorcist Posted September 24, 2008 Share Posted September 24, 2008 I'm not sure why my capcha session is null when I try to echo it nothing shows up. <?php $length = 5; $width = 150; $height = 50; //Creates md5 hash $hash = md5(rand(0, 9999)); //creates a code with $length $code = substr($hash, 15, $length); //stores the code into a session $_SESSION['captcha'] = $code; //creates the image $image = imagecreate($width, $height); //creates background and text colours $background = imagecolorallocate($image, 0, 0, 0); $text = imagecolorallocate($image, 255, 255, 255); //creates the image imagefill($image, 0, 0, $background); //Specifies font and text imagettftext($image, 42, 8, 12, 60, $text, "captcha.ttf", $code); //Tells the browser what kind of image is being outputted. header("Content-Type: image/png"); //creates the image imagepng($image); //frees up resources imagedestroy($image); ?> this is how i included it. <img src="captcha/captcha.php" alt="captcha" /> Link to comment https://forums.phpfreaks.com/topic/125574-solved-captcha-session-null/ Share on other sites More sharing options...
ratcateme Posted September 24, 2008 Share Posted September 24, 2008 you need to call session_start() at the top of both of your pages Scott. Link to comment https://forums.phpfreaks.com/topic/125574-solved-captcha-session-null/#findComment-649251 Share on other sites More sharing options...
Eggzorcist Posted September 24, 2008 Author Share Posted September 24, 2008 can I just put session_start() in my config.php? Link to comment https://forums.phpfreaks.com/topic/125574-solved-captcha-session-null/#findComment-649262 Share on other sites More sharing options...
waynew Posted September 24, 2008 Share Posted September 24, 2008 If php config is included at the top of every page and your including the file you posted here, then yea, you should be able to. Link to comment https://forums.phpfreaks.com/topic/125574-solved-captcha-session-null/#findComment-649272 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.