Need help with handling sessions

First off, I am very green to PHP and mySQL. I know enough to get stuck constantly but really want to learn.

What I am trying to accomplish is creating a common site design that displays different customers info to make the site appear as theirs. It is very basic using the logo company name etc.

My question is what’s the bast way to make sure the session uses the same ID on all pages of the site without the visitor entering info in a form?

Ultimately, I would like the visitor to type in domain.com/customer and have that pass the correct information from the DB to load the right logo etc. I understand this would be a mod rewrite and it seems I can add that portion once everything is functioning right. Currently, it will work if the id is added to the url (?ID=4) but I am not sure how to continue passing that ID between the pages. I know I could just have it dynamically pull the id into every link and send it that way but my problem there lies in the fact that the client will have a CMS on this and will not know how to add the dynamic code necessary to attach the ID to any of the links they might add down the road.

Hope this makes sense and I really appreciate any suggestions you may have.

well if the url was

domain.com/customer1

and you did use mod_rewrite to, behind the scenes, make this a call to;

domain.com/index.php?client=customer1

Then after properly filtering and/or checking vs a white list you could include a file :


//white list example

$allowedclients = array('customer1','customer2') ;

if( !in_array( $_GET['client'], $allowedclients) ) {
// send away
exit();
}else{

$client = $_GET['client'] ;

}

// $client is now considered safe

include $client . '.php';

etc, and in the same way hardcode an image;


echo "<img src='/images/$client.jpg' />" ;

Youll just need some discipline in naming your include paths perhaps, and your images folder.

You can then go on and have a database whose name matches customer1 etc.