I have a simple page where the users log into a chatroom with their logins through http authentication. What I need to do, is pass their login name as the username through the session to other pages they'll access while in the room. This is the coding assuming it goes on the page they're logging in from that I have to initialize and setup the session.
<?
session_start();
if (isset($_SERVER['PHP_AUTH_USER']))
$_SESSION['username'] = $_SERVER['PHP_AUTH_USER'];
?>
<html>
<head>
<title>TESTING</title>
</head>
<body background="http://testsite.com/example/entry2a.png">
<body text="#FFFFFF" bgcolor="#000000" link="#808080" vlink="#808080" alink="#808080">
<font face="verdana,arial,sans-serif">
<center><br>
<table border="0"><tr><td>
<table border="0">
<tr>
<td>
<table border="0" cellspacing="0" cellpadding="0">
<form action="http://testsite.com/rooms/enter/thisroom" method="POST" target="_top"
<tr>
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="20" align="right"><font size="-1">Screen Name: </font></td>
<td height="20"><input name="USER" value="Tester"></td>
</tr>
</td>
</table>
<td width="4"> </td>
<td>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="20" align="right"><font size="-1">Entrance: </font></td>
<td height="20"><input name="SAYS" value="Enters the room..."></td>
</tr>
</td>
</table>
<td width="4"> </td>
<td>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="20" align="right"><font size="-1">History: </font></td>
<td height="20"><input name="HISTORY" value="20" size=2></td> </tr>
</td>
</table>
<td width="4"> </td>
<td>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="20" align="right"><font size="-1">No Pics: </font></td>
<td height="20"><input name="NOPIC" value="1" type="checkbox" checked></td>
</tr>
<tr>
<td height="20" align="right"><font size="-1">Save name: </font></td>
<td height="20"><input type="checkbox" name="SAVE" value="1"></td>
</tr>
</table>
</td>
<td width="4"> </td>
<td>
<table border="0" cellspacing="0" cellpadding="0">
<td height="20" colspan=3>
<input type=hidden name="ACTION" value="says to">
<input type=hidden name="WHOTO" value="ALL">
<input type=submit value="Click to Enter if 18+"></td>
</tr>
</table>
</form>
</table>
</table>
</td>
</tr>
</table>
</td></tr></table>
</body>
</html>
Then on subsequent pages, I have:
<?php
if (session_id() == "")
{
session_start();
}
?>
At the top of each page (though only one really needs the session name to pull directory information from a user folder to populate a dropdown list through php). On the subsequent page I can find the directory, but I can't find the user folder, presumably because the session name isn't being passed on and I'm not quite sure what I'm missing.