• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

mysql query -vs- cookie

Explorer ,
Oct 20, 2015 Oct 20, 2015

Copy link to clipboard

Copied

After the initial load - which will require a query regardless - is it faster on subsequent page loads to pull cookie data, or just re-run the same query at the top of each page - or is it about the same?

Thanks in advance

Views

453

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 20, 2015 Oct 20, 2015

Copy link to clipboard

Copied

For log-ins, I always set session variables.  

Cookies are client-side. Not so good if JS or Cookies are disabled.

Nancy O.

Nancy O'Shea— Product User, Community Expert & Moderator

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Oct 20, 2015 Oct 20, 2015

Copy link to clipboard

Copied

Pulling a cookie from the users computer to the server would be significantly slower than a mysql query, assuming the query is very simple and the table isn't huge.

But you could store cookies and session data on the server. Maybe your question requires more explanation.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Oct 20, 2015 Oct 20, 2015

Copy link to clipboard

Copied

LATEST

For log-ins, I always set session variables.  

Cookies are client-side. Not so good if JS or Cookies are disabled.

By default, php session variables use a cookie to store the session ID. So even if you're using session variables and you haven't explicitly told your server NOT to use session cookies (which will instead use a GET parameter to retrieve session data = not as secure as using default cookie for session id) then it's still not so good if cookies are disabled.

More info at Do PHP sessions set any cookies? - Stack Overflow

best,

Shocker

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines