[solved] advice needed for sessions/headers...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
robster
Forum Contributor
Posts: 360
Joined: Wed Jul 16, 2003 8:28 am
Location: Sunshine Coast, Australia

[solved] advice needed for sessions/headers...

Post by robster »

Hi all, please note this thread taught me about sessions: viewtopic.php?t=34272&highlight=session

Just wanted to add I have a problem, and I understand you have to create your session before output headers.

But here is my problem.

My page (let's call it registration.php) is in fact made up of these elements, in this order via include function:

header.php
menu.php
registration_sidebar.php
registration_maincontent.php
footer.php

header.php and menu.php are included at the start of each script and are vital, they are uniform through out the site and give it uniformity etc.

The problem is, I need to start a session for registration.php (which encapsulates all the other php files) and I need to call it from registration_maincontent.php.

How can I possible do this if the header.php and menu.php have already been included and ran?


Do I have to start a session at the header.php file (and have it do this for the whole site, even though I only need it here and there) or do I have a popup registration form, that is only registration_maincontent.php (and lose continuity of the site, not to mention introduce a popup, which is against my religion ;)).


I'd really appreciate some advice on this one.

Kindest regards,

Rob
Last edited by robster on Sun Jun 12, 2005 1:35 am, edited 1 time in total.
User avatar
robster
Forum Contributor
Posts: 360
Joined: Wed Jul 16, 2003 8:28 am
Location: Sunshine Coast, Australia

Post by robster »

I knew this would happen, I solved it ;)


At the start of registration.php I simply have this:

Code: Select all

<?
//start the session
session_start();
$page_title = "Test session page";
include "header.php";
?>
It then sets the session before the header is displayed and it is only for the registration page ;)

Gotta love it, sorry to take up your time, move along, nothing to .....

:roll:
Post Reply