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 8642411
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T11:46:11+00:00 2026-06-12T11:46:11+00:00

I am using Symfony2 but this question is pretty general. I want to login

  • 0

I am using Symfony2 but this question is pretty general.

I want to login a user and right after the login, let him choose from a certain amount of “roles”. These roles are objects in the database carrying a lot of configuration with them.

Question: What is the best practice of storing what role the User chose?

Session? But it’s bad practice to store objects in sessions, isn’t it?
Id of the role in the Session?
Id (or a hash of it) of the role in a cookie?

Thanks for your thoughts.

  • 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-06-12T11:46:12+00:00Added an answer on June 12, 2026 at 11:46 am

    Definitely store the session ID instead of the whole object. Specially if the object’s data won’t change from user to user. In fact, if the object’s data won’t change over time, you could potentially use one of several techniques to cache it.

    Whether you use cookies or sessions to store the information depends on your requirements. If you need to store additional data (other than the ID of the role), and require such data to be safe from being edited, then you should consider using sessions, since they prevent the user from editing the stored data manually. Otherwise, using cookies is more efficient, since the server doesn’t have to deal with all the hassle of session storing and retrieving.

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

Sidebar

Related Questions

I've been using Symfony for a long time but I'm new to Symfony2. After
I'm using Symfony 1.4 with Doctrine. Sorry if this is a silly question but
I'm using Symfony2 Framework, and this is what I want to do: I want
I' using Symfony2.1 and I want to do something like this: Welcome page before
I'm using Symfony2 and FOSUserBundle. This question is extensible to any other bundled form
I've seen some question here about almost the same thing, but, after following their
This question is not strictly related to Symfony 2, but as I use Symfony
I am using Symfony2 flash messages in my forms to build different views after
I'm using Symfony2 Framework, and I want to update an entity with data from
I've been googleing this question but I can't find anyone with my same problem...

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.