session variable

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
shubhangi
Forum Newbie
Posts: 4
Joined: Wed Jul 08, 2009 6:46 am

session variable

Post 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...
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: session variable

Post 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.
There are 10 types of people in this world, those who understand binary and those who don't
SvanteH
Forum Commoner
Posts: 50
Joined: Wed Jul 08, 2009 12:25 am

Re: session variable

Post 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.
Post Reply