Two Sessions Questions
I am developing a members site, and trying to make it template and DB driven, so it can be transportable between domains.
Each page that is called makes use of include statements to bring in the constant information that is found on every page

Sample page call

<?php

include '../all_inc/pghead.php'; 
//(starts session / connects to DB / includes functions / Queries DB for site details, email, url, etc.  then gets member information from DB / checks to see if ‘Logged In’ / sets up html and <head)

include '../all_inc/pgtop.php';
//(Does the basic html stuff. : closes head tag / body / sets up primary table / displays header graphic / leaves open <tr   and <td   for the body of the page to be displayed)

include '../all_inc/body_table_top.php';
//(Simply opens the body <table  and displays left navigation menu, and leaves <tr <td open for the main body file to be included into for display)

include 'body_verifyemail.php';
//(Does whatever that page is supposed to do)

include '../all_inc/body_table_bottom.php';
//(Nothing more then </td>   </tr>   </table>  left open in table top)

include '../all_inc/pgbottom.php';
//(Closes td and tr left open in the pgtop.php / displays the footer, etc /  closes table left open in pgtop / closes body and html opened in pghead and pgtop)
?>

That is it in a nutshell, and it makes every page look identical.

Now the questions:

FIRST :
When you assign a value to a session variable
$_SESSION = $_POST[‘user’];

From that point on, to access that value:
do you have to use $_SESSION or is it just $user

SECOND:
Would it be better to assign session variables to all the data that is gathered in the pghead from the DB queries, and not have to do the queries each time a page is loaded, or is it better to do the queries?

Actually THIRD:
Does this look like a good approach to site building?

If a live URL would help, I can provide that, but it isn't a 'live' site, just a test and development site.

I have gotten good information/advice here, so I trust your feedback.

Thanks in advance
Doug

Recommended Answers

All 3 Replies

The first question
You will use $_SESSION after that or you can say
$user=$_SESSION on the top of the page (or in your case pghead.php)

Second question
Depends...
Read up about session security before you decide what to store there

It is hard to believe that it has been 8 hours, and no response at all. My experience here has been quick resolutions to questions.

Has anyone got any idea on the answers?

The question on accessing variable data is one that rises from the fact that I have seen it stated both ways in my searching for answers on google, so decided that I could get a straight answer here.

Anyway, any help would be greatly appreciated.

OK, well I don't know that this is resolved, but I will marked it solved just to avoid cluttering up the live thread display.

Thank You Setvir for your response.

Doug

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.