I have a template file containing all my headers, footers, and general information. It includes relevant content for the current page (two-stage presentation template).
I am trying to configure a login system using PHP session variables. I can set a variable, and sometimes they work, but sometimes they disappear. Clicking on links will sometimes make them return.
My site
Sign in with
username: test password: test
var_dumps session_id and $_SESSION above.
Click "Home." If session variables disappear, click on the home button (it may take up to 10 times) to view session information. Click on another navigation, and sometimes the session information gets up, and sometimes not.
Here is the session code at the top of my template file.
<?php session_start(); require './classes/DBInterface.php'; $db = new DBInterface(); if($_REQUEST['submit'] == 'Login') { $username=$_POST['username']; $password=$_POST['password']; echo '-- login -- '.$username; $rs = $db->verify($username,$password,"admin",0); $admin = $rs->current(); if ($rs->valid()) { $_SESSION['username'] = $username; } } echo ' -- session id -- '; var_dump(session_id()); echo ' -- session var -- '; var_dump($_SESSION);
I am using PHP5.
php
Emily
source share