I am, admittedly, a novice with PHP and am trying to learn sessions. I have created a small test script to learn sessions:<?PHP session_start(); $_SESSION['test_session'] = "Hello World"; echo "The variable \$test_session is $test_session"; ?>
The problem is, the variable $test_session isn’t working. It doesn’t post to the page. All I get from the echo line is "The variable $test_session is " (I have tested the variable inside and outside of the string, so it’s not how its structured in the echo call.)
I have tried the older session_register() function with the same script and it works fine, but the variable won’t pass to the next page, which script is as follows:<?php session_start(); echo "
The content of \$test_session is $test_session"; ?>
I have checked that I am running PHP 5.2.x for my site. Am I missing something? This is the most basic script you could do and it should work. I tested it with another host with which I have an account and the $_SESSION call works just fine there, as well as passing the variable to the following page, with the exact same script.