Link to home
Start Free TrialLog in
Avatar of awarraic
awarraicFlag for United States of America

asked on

How do I enable session variables in WAMP5 2.0

Session variables are not working at all in WAMP5, any suggesions?
thanks.
Avatar of Oddsen84
Oddsen84
Flag of Norway image

Have you done session_start(); ???
Avatar of awarraic

ASKER

Yes I did.
Here are three pages that I have.
Page 1 - login page ---------- login in and sending the lgoin info to page 2
<form action="auth.php" method="gett">
     Please Log In
      <label for="user_name">Username* </label>
        <input type="text" name="user_name" id="user_name" />
        <label for="user_password">Password*</label>
        <input type="password" name="user_password" id="user_password"  />
        <input type="submit" name="submit" id="submit" value="submit"  />
</form>

Page 2 ------------------------------- setting up the session variables
<?php
$input_username = $_GET['user_name'];
$input_password = $_GET['user_password'];

$_SESSION["authenticate"] = $input_username;
$_SESSION["password"] = $input_password;
header("Location:mainAdmin.php");
?>

page 3 ---------------------- printing out passed session values
<?php session_start();
echo "test 1 = ";
echo $_SESSION["authenticate"];
echo $_SESSION["password"];
?>
ASKER CERTIFIED SOLUTION
Avatar of Oddsen84
Oddsen84
Flag of Norway image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Oh and by the way you need to make session_start(); one of the first lines of code you write. And I am unsure but I don't think you can echo or print any thing before that line of code...
You also have to include session_start(); on page 2 prior to setting the session variables.
Yea sorry, have that session_start(); on page 2, just mistypoed in here when I cleaned the code a lil bit.
Thanks much.