douchengjue9892 2016-04-05 14:43
浏览 53
已采纳

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

  • 写回答

1条回答 默认 最新

  • donglin5770 2016-04-05 14:51
    关注
    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题