Skip to main content
Participant
October 20, 2015
Question

mysql query -vs- cookie

  • October 20, 2015
  • 3 replies
  • 553 views

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

    This topic has been closed for replies.

    3 replies

    October 20, 2015

    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

    Rob Hecker2
    Legend
    October 20, 2015

    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.

    Nancy OShea
    Community Expert
    Community Expert
    October 20, 2015

    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