Page 1 of 1

session variable

Posted: Thu Jul 09, 2009 3:52 am
by shubhangi
i tried creating a session variable.

Wht r necessary steps to do..

i tried with the following..
session_start();
session_register ("my_username");
$my_username = $credentials['username'];
//here $credentials['username'] will display the actual username

Now i want to use ths username in other file.
so i tried
session_start();
session_register ("my_username");
echo"hello";
echo $_SESSION['my_username'];

i also tried $my_usename;

nothing is wrking
the variable is null and not displaying anuthg.
Pls helpppp...

Re: session variable

Posted: Thu Jul 09, 2009 4:28 am
by VladSun
http://us2.php.net/manual/en/function.s ... gister.php
Warning

This function has been DEPRECATED as of PHP 5.3.0 and REMOVED as of PHP 6.0.0. Relying on this feature is highly discouraged.
Please, use [ php ] your code here [ /php ] tags as you've been asked to already.

Re: session variable

Posted: Thu Jul 09, 2009 6:13 am
by SvanteH
Which would mean

Code: Select all

<?php
  session_start();
  $_SESSION["my_username"] = "test";
?>
is enough and you can do echo

Code: Select all

$_SESSION["my_username"];
on the next page.