Board index   FAQ   Search  
Register  Login
Board index php forum :: Database mySQL & php coding

Database or sessions?

Codes here !

Moderators: macek, egami, gesf

Database or sessions?

Postby Batman » Sun Apr 20, 2003 3:06 am

Hi

I'm currently trying to write my own forum, and I was wondering about something. When a user logs in, a session is started. Depending on the "level" of the user (visitor, moderator, admin, ...) he will have different options: reply to topic, move topic, delete topic, etc. In other words, each time a user opens a topic, a check needs to be done to see what level he is, which determines what options will be available on that page.

Is it preferable to store this userlevel in a session (I will use the standard PHP4 session functions), or should I look it up in the MySQL database each time (i.e. his username is stored in a session and the rest is retrieved from the dbase with that username as an identifier)? I'm not only wondering about this in terms of speed, but also in terms of how much session-info the server can generally store without getting into memory/diskspace/speed trouble.

Thanks!
Batman
New php-forum User
New php-forum User
 
Posts: 2
Joined: Sun Apr 20, 2003 2:59 am
Location: Leuven, Belgium

Postby liquedus » Sun Apr 20, 2003 6:01 am

i would use a session, on a busy server doing such requests would only create unneccessary traffic and might slow down crucial parts of your site, but thats only my opinion.
liquedus
php-forum Active User
php-forum Active User
 
Posts: 266
Joined: Tue Apr 08, 2003 5:18 am
Location: Ottawa, Canada

Postby *JaH* » Sun Apr 20, 2003 6:26 pm

I would use session control AND the database, at least for the admins...then it's best secured :)
*JaH*
New php-forum User
New php-forum User
 
Posts: 80
Joined: Fri Jan 31, 2003 4:18 pm

Postby Batman » Tue Apr 22, 2003 8:48 am

Thanks for the feedback, guys. Good point about (admin) security. Looks like a mix may indeed me the best solution.
Batman
New php-forum User
New php-forum User
 
Posts: 2
Joined: Sun Apr 20, 2003 2:59 am
Location: Leuven, Belgium

Postby Joan Garnet » Sun Apr 27, 2003 3:01 am

Then it would be nice to secure it a little bit more by using encryption methods such MD5, which comes by default in the php core. It makes everything less readable :D
urlencode is another option too.

Bye!
User avatar
Joan Garnet
Moderator
Moderator
 
Posts: 387
Joined: Sat Aug 03, 2002 2:56 am
Location: Mars


Return to mySQL & php coding

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron