Problems with sessions

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Collen
Forum Newbie
Posts: 1
Joined: Sat Jan 24, 2009 10:44 am

Problems with sessions

Post by Collen »

Hi!

I've got problems with captcha script.

I include it into my pages this way:

Code: Select all

<img src="captcha.php">
The script has line:

Code: Select all

$_SESSION["captcha"]=$str;
It generates captcha but $_SESSION["captcha"] remains empty.

If I use

Code: Select all

<? include "captcha.php"; ?>
everything is OK - $_SESSION["captcha"] isn't empty (but in this case as you know I get symbols instead of captcha image).

I've tried 3 different captcha scripts - all have the same problem.

So I guess it's not about scripts, the problem is in my hosting settings (everything works fine locally) but I can't figure out which exactly. Could u please help?
User avatar
Chewbacca
Forum Newbie
Posts: 5
Joined: Fri Jan 23, 2009 1:57 pm

Re: Problems with sessions

Post by Chewbacca »

Here are a some ideas:
  • Make sure that the captcha script is calling session_start() before setting any session data.
  • Pass the session_id to the captcha script and call session_id($_GET['id']) or something similar to ensure that the captcha script is using the same session_id as the calling script.
  • Compare the output of print_r(get_session_cookie_params()) in the captcha script and in the calling script.
http://us.php.net/manual/en/function.session-start.php
http://us.php.net/manual/en/function.se ... params.php
http://us.php.net/manual/en/function.session-id.php

-Chewbacca
Post Reply