Forgive me if this doesn't make too much sense but I've been working on this
project all day and my brain is a bit fried.
To make some of my code more readable I made a file (called urls.inc) which
I include in my PHP scripts. This file contains functions to return a URL
with the session id tagged on the end. I've now found out that the session
id returned by the functions in urls.inc is not necessarily the current, and
more importantly correct, session id. I need to know if there is a way to
establish the current session id within the included file.
For info, I've built the scripts so that the session id is passed from page
to page to avoid using cookies (part of the challenge, it's a college
project) so I need the urls.inc file to know which session id to pass back
otherwise it all goes a bit squiffy.
Here's urls.inc :
<?php
session_start();
function logoutURL()
{
return "logout.php?PHPSESSID=" . session_id();
}
function adminURL()
{
return "admintools.php?PHPSESSID=" . session_id();
}
function homeURL()
{
return "main.php?PHPSESSID=" . session_id();
}
?>
These are called like this :
echo "<h3 align=\"center\"><a href=\"" . adminURL() . "\"
target=\"mainFrame\">Administration Tools</a></h3>";
If it turns out that there's no way to do what I'm after then it's not big
deal because I can change the URL line to :
echo "<h3 align=\"center\"><a href=\"admintools.php?PHPSESSID=" .
session_id() . "\" target=\"mainFrame\">Administration Tools</a></h3>";
I just wanted to show some initiative and keep the code as tidy and as
possible.
Thanks for any help,
Pete.