Page 1 of 1

Problems with sessions

Posted: Sat Jan 24, 2009 11:09 am
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?

Re: Problems with sessions

Posted: Sat Jan 24, 2009 12:49 pm
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