ATLChris
ATLChris

Reputation: 3296

PHP Mobile Detect

I am writing a mobile detect script to use across multiple projects and I wanted to gage the community to see if you all can help me figure out the best way todo something.

My mobile detect script works great and directs traffic as expected. The part I wanted to get my fellow programmers opinion on is the "override" feature. Allowing people to view the main site if they wish. My questions for you all, is how should I control the override? Should I use sessions to store the override variable or should I use cookies?

My first thought was sessions, but this script will be included across hundreds of locations and I am concerned about interference in the sessions with some of the projects. For instance, if one of the projects destroys the sessions for logging in and out a user, we will lose the "override" setting also.

What are your thoughts?

Upvotes: 0

Views: 503

Answers (4)

Robin Orheden
Robin Orheden

Reputation: 2764

Cookies. Because the option is device specific.

Upvotes: 1

Damien
Damien

Reputation: 5882

Use a cookie:

  • you have nothing to store
  • you can scale
  • you can read the cookie before generating any content (by reading HTTP request headers)

I should have recommand LocalStorage too, but it's just for the fun, cookies are good enough.

Upvotes: 1

clement
clement

Reputation: 4266

I advice you to use cookies, even if the user is changing of device / clean cookies, programmatically, cookies is the must for your problem

Upvotes: 2

Alex Howansky
Alex Howansky

Reputation: 53636

I would just use a cookie, I think session management is overkill for this requirement.

Upvotes: 1

Related Questions