Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

PHP $_SESSION being called by regular variable?

I have a code that stores data into a variable then sets a session with a md5 hash of the data, plus salt: (I use it to generate characters for captcha)

<?php

session_start();

$code = strtoupper(substr(md5(uniqid(rand())), floor(rand(0,26)), 6));

$_SESSION['code'] = "1s3LK" . md5($code) . "aDB2";

echo $code;

?>

On my localhost, the code returned is a 6 character code.

On my actual webhost (Hostgator), the code returned is the session data.

Is this a known issue, a problem with my code or should I contact my webhost to find out what is going on?

To counter it I have had to change the name of the session variable but I'd rather not do that!

Update:

Just JR,

Obviously you didn't read, or understand, my question.

The problem is that, on my WEB SERVER, echoing $code is returning the data stored in the SESSION, as opposed to the $code variable.

Also try not insulting me next time you choose to reply to something without reading my question.

1 Answer

Relevance
  • 10 years ago
    Favorite Answer

    You echo $code, as a substring of 6 characters. What do you expect?

    echo ($code);

    echo ($_SESSION['code'])

    and watch the difference...

    There is no "issue", but you have one with your logic...

Still have questions? Get your answers by asking now.