session help


#1

Dear All:

I wrote the below script in the login.php:

[php]
session_start();

$_session[“username”] = $uname;
$_session[“password”] = $pwd;

echo “”;

[/php]

and the second page i wrote the below:

[php]

session_start();
print $_session[“username”];

[/php]

when i execute the script, the error "Notice: Undefined variable: _session in C:InetPubwwwroothomelegance123test.php on line 3 " prompt.

Anybody can advise me how to resolve the above errors.

Thanks


#2

I don’t know this is the problem, but try:

[php]<?
session_start();

$_SESSION[“username”] = $uname;
$_SESSION[“password”] = $pwd;

echo “”;

?>[/php]
[php]<?
session_start();
print $_SESSION[“username”];
?>[/php]
See if that changes anything.

Also, you will want to make sure that $uname and $pwd actually contain anything. Echo them out or swap them out of a hard coded string.


#3

the $_SESSION is case sensitive. :)


#4

I was pretty sure, but I had never tried it and couldn’t remember what I had read so I figured I had better not set my words in stone! :)