1

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

Community
  • 1
  • 1
bepster
  • 93
  • 1
  • 8
  • Why do you need 3 databases? A database is not like a file, you can have many tables within the same database – RiggsFolly Apr 05 '16 at 14:48
  • Associate a Company with each login. Then use that company to control what that user sees from within a single database – RiggsFolly Apr 05 '16 at 14:51
  • RiggsFolly each database is a separate company, each database contains sage accounting data for each company. So the dashboard will display different results per database – bepster Apr 05 '16 at 14:54

1 Answers1

0
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.

Community
  • 1
  • 1
Tommy
  • 377
  • 1
  • 9
  • Thanks Tommy, that's really good information. I think Cookies might be the best way to go for me as the variable only has to hold a value e.g. 1, the if statement in the page can write the dbname dependant on the value. The cookie would also mean that it would remember the user's choice if they navigate directly to a page – bepster Apr 05 '16 at 15:27
  • No problem my friend, just trying to help. Ultimately, if you've never used either before, and If I was you, I would try and create a quick demo application utilising both of them, and see which one you either prefer, or suits your application more. It will probably save you time too later on as you'll have a general idea of what to do already. – Tommy Apr 05 '16 at 15:39