these are my php files that show my script about session : test.php <? session_start(); session_register("testVar"); $testVar = "HI PHP"; header("Location:test2.php"); ?> tes2.php <? session_start(); echo $testVar; ?> the problem is, the browser don't show anything when i run test.php. i check my tmp folder (c:\apache\tmp\),and there are 2 files session id that been created, BUT one file save the variable, and other doesn't. and the last file created is the one without any content. i'm sorry if my english is mess, i can't write english well. thanx
session_register() is deprecated (no longer used), and Register Globals isn't on. Try this: test.php <? session_start(); $_SESSION[testVar] = "HI PHP"; header("Location:test2.php"); ?> test2.php <? session_start(); echo $_SESSION[testVar]; ?> -the mole
i've tried that script to... but it still didn't worked out. i don't know if this because of my PHP.ini settings or not, b'cause before i formatted my computer, it's worked well. i've tried to change the header(location:....) with <a href=... > </a> and the session is working... but in the url my session id is shown.
I checked above script it is displaying the value of $testvar. But session_start on test2.php is creating problem, instead of header("Location:test2.php"); use < a href ="" then it will work fine
php.net/manual/en/function.session-start.php stop treating these forums as clutches.. the information is very freely available on google and the php.net documentation.. <?php // page1.php session_start(); echo 'Welcome to page #1'; $_SESSION['favcolor'] = 'green'; $_SESSION['animal'] = 'cat'; $_SESSION['time'] = time(); // Works if session cookie was accepted echo '<br /><a href="page2.php">page 2</a>'; // Or maybe pass along the session id, if needed echo '<br /><a href="page2.php?' . SID . '">page 2</a>'; ?>