I have a session that is created and stored. On another page, I want to pull two variables from this session. One of the variables I want to echo as a welcome and the other I want to use in a query to update a mysql table. I just can't quite seem to figure out the correct wording as I have really not worked with sessions and someone else created the initial code. The session name is what is really giving me the trouble.
Here is the code for naming the session:
$directory = "http://$serverName/".$journalName['db'];
mysql_connect('server','user','pass');
mysql_select_db($journalName['db']);
ini_set('session.use_trans_sid', false);
ini_set('session.use_only_cookies', true);
session_name($journalName['db']);
session_set_cookie_params(6*60*60); // 6 hrs until login cookie expires
session_start();
It has the possibility of three different session names. If I do a print of the array (print_r($_SESSION);) here is what shows up:
Array ( [loggedin] => 1 [person] => 1 [account_id] => 1 [order_id] => [type] => individual [unlimited] => yes [status] => active [agreeterms] => no [bounced] => no [subscription_begin] => 0000-00-00 [subscription_end] => 0000-00-00 [contact_name] => Doe, Jane [email] => jane.doe@gmail.com [email_cc] => [institution] => IRA [net_addresses] => [department] => CELT [phone] => 123-456-9383 [address] => 303 S. Patterson Ave [city] => Butte [state] => ID [zip] => 12345 [country] => United States [tech_contact] => [tc_phone] => [tc_email] => [last_login] => 2014-12-15 13:20:24 [last_access] => 2012-03-28 13:45:23 [administrator] => yes [notes] => [last_reset] => 2011-11-19 13:36:59 [last_notified] => 2007-08-14 [combo] => no )
I want to pull the variable contact_name for display at the top of the page and I want to pull the variable email and use it to run and update query. Here is what I currently have to pull the contact_name:
<?php echo "<h2>Account Owner or Contact Name:" .$_SESSION[["contact_name"]]. ",</h2>"; ?>
It is not working at all. Sessions really have me flumoxed at the moment.
Account Owner or Contact Name:" .$_SESSION["contact_name"]. ",
"; now shows up on the page as: Account Owner or Contact Name:, reflecting just the html and not the variable. – learning_curve Dec 16 '14 at 18:09