Is there a way to have a session use two variables instead of just one?

For instance:

$_SESSION['$email.$level']
$_SESSION['level'] = 'whatever';
$_SESSION['email'] = 'whatever';
commented: This solved my issue of saving multiple values to the session. +2

if $email equals 'joe@gmail.com' and $level equals 1, Then if you are TRYING to set: $_SESSION['joe@gmail.com.1']='...' , then the above will not work. You need to use DOUBLE quotes so that the variables are evaluated: $_SESSION["$email.$level"] Perhaps what you are after is something like:

$_SESSION['email_level']=$email.PHP_EOL.$level;

Then later on if you need those values, you explode() on the PHP_EOL character:
list($email,$level)=explode(PHP_EOL, $_SESSION['email_level']);
echo 'Email',$email,'<br />';
echo 'Level',$level,'<br />';

OK. I got that issue figured out but now the question is "Is there a way to recall a value when it is used in a customization script as part of an include_once?".

loginphp.php code:

if ($email==$dbemail&&md5($password)==$dbpassword)
      {
        if ($dblevel==0)
        {
          $_SESSION['email'] = $email;
          $_SESSION['Level'] = $dblevel;
          $_SESSION['name'] = $dbname;
          session_destroy();
          header('Location: index.php');
        }
        elseif ($dblevel==1)
        {
          $_SESSION['email'] = $email;
          $_SESSION['Level'] = $dblevel;
          $_SESSION['name'] = $dbname;
          header('Location: member.php');
        }

member.php code:

<?php

  session_start();

  if ($_SESSION['email'] && $_SESSION['Level']==1)
    include_once('Member_Library_Trial.html');
  else
    die("You must be logged in!");

?>

Member_Library_Trial.html code

<?php
session_start();
?>

Member_Library_Trial.html code continued.

<div id="Text1">Congratulations <?php $_SESSION['name']?></div>

rename Member_Library_Trial.html to Member_Library_Trial.php

AND also change: <?php $_SESSION['name']?> to: <?php echo $_SESSION['name'];?>

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.