Forum Moderators: coopster

Message Too Old, No Replies

PHP Sessions with mysql

         

bobnew32

9:31 pm on Aug 19, 2003 (gmt 0)

10+ Year Member



Ok, I now understand php sessions and how to utilize them on webpages, but I don't understand why some (all) forums/sites would want to store sessions ids in a mysql forum. Why/What would be the purpose of that?

dwidmer

6:58 am on Aug 20, 2003 (gmt 0)

10+ Year Member



Hi

I'm kinda a newbie myself, but I think the reason behind storing sessions in a mysql database is that it gives you more possibilities. For example, if you have an online community and you want to display who's online right now, you need a place where all the active sessions are stored. You simply save the session ID and the corresponding username (and/or UserID) in a table and then it's pretty simple to tell who's online at the moment.

You can probably do much more things, which I haven't discovered yet :)

Dan

SalmoLes

9:51 am on Aug 20, 2003 (gmt 0)



Sessions and Cookies.

Personally I am very much anti-Cookies period.

When you open up a PHP session, like all Server-side Session functions including ASP, at least one single cookie has to be created on the client PC. This in itself is no big deal, but if you are expecting a cookie-less client to use your system, the Session function will fail.

This is why I use database driven (MySQL, Interbase etc) Session functions, which passes the session string between pages either as a Post or a Get to create the seamless illusion of Statefulness.

Also, as DWIDMER (Hi Dan) suggestes, you can monitor and gauge browser activities more precisely if it is stored and controlled using a database.

Rgds, Les