News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Sessions / cookies etc

Started by Owdy, December 15, 2003, 06:56:22 PM

Previous topic - Next topic

Owdy

[Unknown] xplained to me how action=unread works:
Quote from: [Unknown] on December 15, 2003, 06:12:50 PM
You hit the site, and don't have the cookie. (not really a cookie, but we'll call it one.)  So, it gives it to you, and then updates the database saying, "okay they visited... NOW."  At the same time, it gets your last visit for the "cookie" it sets and uses that.

Then you go to another browser/computer.  It also doesn't have the "cookie," so SMF again sets it and says, "okay, another visit... NOW," which promptly ruins everything so that your "last visit" is, well, the other browser.

Ok, i wanna learn more of this. We all know, u can log in to SMF without cookies. Ok, how? It uses sessions too? OK, what are sessions? Im complete noob about this.


Former Lead Support Specialist

Tarvitsetko apua SMF foorumisi kanssa? Otan työtehtäviä vastaan, lue:http://www.simplemachines.org/community/index.php?topic=375918.0

pulpitfire

Quote from: Owdy on December 15, 2003, 06:56:22 PM
[Unknown] xplained to me how action=unread works:
Quote from: [Unknown] on December 15, 2003, 06:12:50 PM
You hit the site, and don't have the cookie. (not really a cookie, but we'll call it one.)  So, it gives it to you, and then updates the database saying, "okay they visited... NOW."  At the same time, it gets your last visit for the "cookie" it sets and uses that.

Then you go to another browser/computer.  It also doesn't have the "cookie," so SMF again sets it and says, "okay, another visit... NOW," which promptly ruins everything so that your "last visit" is, well, the other browser.

Ok, i wanna learn more of this. We all know, u can log in to SMF without cookies. Ok, how? It uses sessions too? OK, what are sessions? Im complete noob about this.

i think php has a built in variable like "session_id" that generates a long code for each user, to identify them and thier "session". 

http://www.php.net/manual/en/function.session-id.php

Gobalopper

#2
Instead of storing things on your computer in a cookie, which is very limiting, you store things in a session which is on the server.

http://www.php.net/manual/en/ref.session.php

Compuart

Quote from: Owdy on December 15, 2003, 06:56:22 PM
[Unknown] xplained to me how action=unread works:
Quote from: [Unknown] on December 15, 2003, 06:12:50 PM
You hit the site, and don't have the cookie. (not really a cookie, but we'll call it one.)  So, it gives it to you, and then updates the database saying, "okay they visited... NOW."  At the same time, it gets your last visit for the "cookie" it sets and uses that.

Then you go to another browser/computer.  It also doesn't have the "cookie," so SMF again sets it and says, "okay, another visit... NOW," which promptly ruins everything so that your "last visit" is, well, the other browser.

Ok, i wanna learn more of this. We all know, u can log in to SMF without cookies. Ok, how? It uses sessions too? OK, what are sessions? Im complete noob about this.
The important thing about sessions and cookies is that PHP remembers that you're still the same person each time you request a page. The traditional (YaBB SE) way was to only use cookies. The cookies have a username and an encrypted password stored in them and each time you click it compares the login data from the cookie with the data from the database.

The trick with sessions is that your session is tracked server side. This is done by giving the user a unique ID (session ID), usually by using cookies. If however a browser doesn't support cookies (for privacy or security reasons most of the time) SMF will replace all url's by url's that have a session ID in them. http://www.simplemachines.org/community/index.php becomes http://www.simplemachines.org/community/index.php?PHPSESSID=9349582739586324905 . This way a user from one page can still be identified as the same user on the next page.
Hendrik Jan Visser
Former Lead Developer & Co-founder www.simplemachines.org
Personal Signature:
Realitynet.nl -> ExpeditieRobinson.net / PekingExpress.org / WieIsDeMol.Com

Owdy

Former Lead Support Specialist

Tarvitsetko apua SMF foorumisi kanssa? Otan työtehtäviä vastaan, lue:http://www.simplemachines.org/community/index.php?topic=375918.0

Advertisement: