Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 554387
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T11:42:15+00:00 2026-05-13T11:42:15+00:00

Is it best to store all the users information in session cookies like this

  • 0

Is it best to store all the users information in session cookies like this on login? Instead of using alot of querys

$_SESSION['id'] = mysql_result($result, 0, 'id');
$_SESSION['name'] = mysql_result($result, 0, 'name');
$_SESSION['email'] = mysql_result($result, 0, 'email');
$_SESSION['ip'] = mysql_result($result, 0, 'regip');
$_SESSION['groupid'] = mysql_result($result, 0, 'group_id');
$_SESSION['style'] = mysql_result($result, 0, 'style');

Or maybe just store ID in session then query on all page:

select * from users where id = $_SESSION['id']
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T11:42:15+00:00Added an answer on May 13, 2026 at 11:42 am

    If you’re going to be using them a lot, sure. Although I’d be careful about storing all of the users data in the Session. Only what is necessary. Keep in mind that well-written queries are cheap on resources. Don’t try to avoid connecting to the database altogether, just be sure that when you do it, you do it well.

    You can test your memory-consumption if you like using memory_get_usage(). But note that session data is stored in a flat file on the system itself:

    session_start();
    echo memory_get_usage(); // 87744
    $_SESSION["user"] = array(
        "name"    => "Jonathan Sampson",
        "id"      => 54680,
        "groupID" => 0285,
        "email"   => "example@somesite.com",
        "style"   => "background-color:#333;color:#f1f1f1"
    );
    echo memory_get_usage(); // 88344
    

    So you can see that it’s really very trivial to store this amount of data.

    See also: Cache data in PHP SESSION, or query from db each time?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.