0

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

For instance:

$_SESSION['$email.$level']
3
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by hielo
2
$_SESSION['level'] = 'whatever';
$_SESSION['email'] = 'whatever';
Votes + Comments
This solved my issue of saving multiple values to the session.
0

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 />';
0

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>
1

rename Member_Library_Trial.html to Member_Library_Trial.php

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.