PHP - 1 Web应用程序 - 多个数据库

Good Afternoon,

We currently have a dashboard written in Classic ASP, it basically returns on the front page titles e.g.

Open Orders - 55 Closed Orders - 66 Won Orders - 77

each title navigates to another page with a table of further information e.g.

Order No | Part Required | Qty | Value 000001 ... 000056 ...

Currently we have 3 copy's of this dashboard, each one connects to a different database e.g. db1.company.com, db2.company.com, db3.company.com, so when you for example add an extra page to db1.company.com you have to make the change on db2.company.com and db3.company.com

I am looking into re writing these into one PHP site, now I'm learning as I go along here so let me know if I've missed anything or can provide some more information...

What I would like to do is have:

One Site e.g. dashboard.company.com

3 buttons on first page e.g. db1, db2, db3.

Each button would then create a variable that can be used across the site to determine which database connector to use e.g.

if variable = 1 $dbname = db1

As far as I understand there is two ways to achieve this.

Cookies

Session variables

Which is the best method / is there a better method?

Thanks,

Mike

A cookie is a bit of data stored by the browser and sent to the server with every request.

A session is a collection of data stored on the server and associated with a given user 
(usually via a cookie containing an id code)

There isn't particularly a better/best method per say, I recommend you do some research on both Cookies and Sessions, as they effectively achieve the same thing, in your case, use the link below for some guidance.

When should I use session variables instead of cookies?

Credits @Daniel Vassallo

I personally prefer the use of Sessions, as I would have to say they are "simpler" to use, just assign and go, but again this is just my personal preference.