No, sessions are not the same as your database. To use variables in a session you'll need to explicitly add the variable to the session itself, like this:
PHP Code:
// place this line at top of page before any output
session_start();
//create a var with a value
$testvar = "myfirstname";
// register the variable into a session
$_SESSION['testvar'] = $testvar;
On another page, you can then do this (again, you need to start the session as above):
PHP Code:
// this will print nothing because the variable hasn't
// been retrieved from the session yet
print "TESTVAR: $testvar";
// now we'll retrieve the var from the session
$testvar = $_SESSION['testvar'];
// this will print the text 'myfirstname'
print "TESTVAR: $testvar";
If you have a customer name saved in the database, you must first pull the name out of the database, then store it in a session.
Quote:
Originally Posted by craigfarrall
Ok so if I have a customer first name saved in the db as 'fname' then I can use:
Code:
$_SESSION['fname'];
Then I can echo that out later to show the fname?
|