Deviant Logo

Problems with calling a variable in a php session?

post details top
May 11th, 2010
post details top


I am new to sessions and I have written a few php programs and want to make a session I have declared Session_start() at the begining then declares $_session=”yes”
if ($pword == $ROW[4])
$_session['login']=”yes”;
else
die (“

In correct password!

“.

Please go back and Log in again

“);
When I try to call it in the next program I get undeclared variable what am I doing wrong?
session_start();
$session = $_session ['login'];
If ($session != "yes")
die ("

Please log in!

“.”Log in again

“);
else
echo”

Welcome

“;

Post to Twitter Post to Delicious Post to Digg Post to Facebook Post to Reddit Post to StumbleUpon

1 Comment

  • solocomputerservices

    You must start a session for each page. So…

    At the top of all of your PHP page that you will use the session for, you must do a check to see if the session is active and if it isn’t, you must start it. Please look below for example:

    //initialize the session
    if (!isset($_SESSION)) {
    session_start();
    }

    I hope that this answers your question.

    Solo Computer Services.com

Leave a Reply

Search

  • Partner links