Forum Moderators: coopster
I have a site map page with approximately 20 different pages listed on it, 10 of which are password protected, 10 of which are not. I want the 10 non password protected page links on my site map page to execute the following PHP command when they are clicked:
<?
session_unregister("CustomerID");
session_unregister("UserID");
session_unregister("FirstName");
session_unregister("AccessLevel");
session_destroy();
?>
How do I integrate this PHP function into the following code so that, when one of these links is clicked, the PHP script above is executed:
<li class="content_text"><a href="index.php">Home Page</a> - The home page for #*$! </li>
<li class="content_text"><a href="login.php">Login Page</a> - The login page for #*$! </li>
However, I don't want the PHP script to execute when a user clicks one of these links:
<li class="content_text"><a href="index-loggedin.php">Home Page</a> - The home page of the Participant Area of xxx </li>
<li class="content_text"><a href="account_update.php">Account Information Page</a> - Update your all of your account information here </li>
All of these links are on the same site map page. How do I execute the PHP script above for only the top two hyperlinks and not for the bottom two hyperlinks?
I cannot put the PHP script in the head area of the different pages (i.e. index.php & login.php) for a variety of reasons. I need this code to be on the site map page and to execute when the hyperlink is clicked. Thanks!
A tried to create a 302 page (index.302.php) with the following code:
<?php
header("Location: index.php");
session_unregister("CustomerID");
session_unregister("UserID");
session_unregister("FirstName");
session_unregister("AccessLevel");
session_destroy();
?>
I then linked to this page (index.302.php) from my site map. However, it seems like the session variables aren't closing because I can still leave the password protected area via the site map for index.php and then return to the password protected area without a problem. I want to prevent people from being able to jump back and forth between the two. As a side note, the php header for index.php (which is not password protected) is this:
<? session_start();?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
The php header for a password protected page is this:
<? session_start();
if($_SESSION['CustomerID'] == "") { header("Location: login.php"); }
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Any further suggestions would be greatly appreciated!
Or, if you are already using some kind of a top_html.inc.php to help maintain your pages and keep them uniform, you could define the conditions for calling the funtions there.
<?
$error = "";
include_once 'unregister.inc.php';
?>
<? session_start();?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Where unregister.inc.php would have this script:
<?php
session_unregister("CustomerID");
session_unregister("UserID");
session_unregister("FirstName");
session_unregister("AccessLevel");
session_destroy();
?>
In other words, can I put this in instead:
<?php
if (coming from sitemap.php)
then...
session_unregister("CustomerID");
session_unregister("UserID");
session_unregister("FirstName");
session_unregister("AccessLevel");
session_destroy();
?>
Thanks!