Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Session cookies

session

  • Please log in to reply
3 replies to this topic

#1 Bertan

Bertan

    CC Regular

  • Member
  • PipPipPip
  • 42 posts

Posted 06 January 2012 - 01:59 PM

I want to make it possible for users to stay logged in on my page. I was going to store the session data in the database. From what I have seen from most session scripts online, data is saved to the database from all users guests and logged in users. Is there any value in saving information about guests if all I want to do is to give the user the ability to stay online. I was thinking about inserting the data when the users logs in and delete all rows with the matching user id everytime the user logs out to keep the session table slim. But I havn't seen anyone doing like this so I figure I might have got something wrong.

Any help on this would be appreciated.

Yours,
Bertan
  • 0

#2 Alexander

Alexander

    YOL9

  • Moderator
  • 3963 posts
  • Location:Vancouver, Eh! Cleverness: 200
  • Programming Language:C, C++, PHP, Assembly

Posted 06 January 2012 - 02:14 PM

A user can automatically be "logged in" when given a session cookie, as each subsequent connection will access that session under common situations. The guest can be given guest permissions, if someone were to log in they could be given better permissions written to their session. The point of user registration (via database) is non-volatile storage, as session length is difficult to be determined or modified or kept safe on the client end. Guests may come and go and have no need for this.

I am unsure what you are really wanting to do, can you give an example?

Alexander.
  • 0

All new problems require investigation, and so if errors are problems, try to learn as much as you can and report back.


#3 Bertan

Bertan

    CC Regular

  • Member
  • PipPipPip
  • 42 posts

Posted 06 January 2012 - 03:32 PM

More or less I was wondering about the necessity of storing session cookies from guests. It felt easier to just insert the session cookie to the database after the user logs in and if the user logs out remove it.

But as you said, guests come and go and have no need of this. So this means there is no reason to save session cookies for guests?
  • 0

#4 Alexander

Alexander

    YOL9

  • Moderator
  • 3963 posts
  • Location:Vancouver, Eh! Cleverness: 200
  • Programming Language:C, C++, PHP, Assembly

Posted 06 January 2012 - 03:53 PM

The session is stored in a temporary file, and the session cookie allows the user persistent access to that specific session with a session identifier. There is no benefit or function to storing the session cookie in the database, especially if a guest has not visited for a few days and the session identifier becomes invalid.
  • 0

All new problems require investigation, and so if errors are problems, try to learn as much as you can and report back.






Also tagged with one or more of these keywords: session

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download