PHP SESSION

For discussion of the BB stats code.
nos

PHP SESSION

Postby nos » Wed Jan 30, 2008 6:54 am

hey guys,

Just wondering how much u guys know about the php session functions.
I was thinking i might setup a session and store the array for the player stats
to a session var.

This would save server load because the you wont have to send a query everytime
the user opens a new page.

does anyone see any problems with using php session is this way?

User avatar
Mort
Alpha-Forum Whore
Alpha-Forum Whore
Posts: 4231
Joined: Thu Dec 01, 2005 10:40 pm

Re: PHP SESSION

Postby Mort » Wed Jan 30, 2008 9:01 am

Personally I have no idea how to use it, but I am aware of what you are talking about.

In effect, our code was never optimised to reduce load for a couple of reasons:
1. We are only a small group so it didn't seem to be an issue
2. It all on my own server so "load" was never any issue with a shared hosting service or anything.

There were all sorts of things we were looking at doing. Some stuff Piers did write to be more client side, like the sorting functions which made a big difference. Previously I had written those as a page reload with the server doing the sorting.

Remember, one of the ideas behind releasing this was to get improvements from other people added in, so if you can do it and it works better... go for it.
Image

nos

Re: PHP SESSION

Postby nos » Wed Jan 30, 2008 4:16 pm

Well i have no problems with how Sessions works but I'm just not completely sure it
will accomplish what im after witch is to cut back on server load for those of us
that have larger numbers of ppl in the stats system database.

In theory i think it should work because u can cut back on a hell of allot
of sql requests just not sure if it will cause other problems.

User avatar
Mort
Alpha-Forum Whore
Alpha-Forum Whore
Posts: 4231
Joined: Thu Dec 01, 2005 10:40 pm

Re: PHP SESSION

Postby Mort » Wed Jan 30, 2008 5:09 pm

I think I found doing lots of smaller requests was better than doing one really big one. Having the client do the work means it needs all the data up front to do it with.

I'd suggest just get v1.0 out the door and monitor the load. If it causes problems then put some limits on the number of people that you can report on at once. I think the "Compare" stats tables are the only ones that would really give you issues.
Image

nos

Re: PHP SESSION

Postby nos » Wed Jan 30, 2008 7:05 pm

well this would be simple to add and it wouldnt change the code at would just mean
the first time the user opens the page a querys the database the stats are stored to sessions var.

When a client loads a page there would be a check on the sessions var to see if it has been
loaded or not, if the check = true then the script would just use the sessions var.

something like

if($_SESSION['stats) {

$stats_array = $_SESSION;

}else{
$stats_array = getStatsData()

}

User avatar
Piers
Comfortable with my sexuality
Comfortable with my sexuality
Posts: 1408
Joined: Fri Dec 02, 2005 7:57 am
Location: Horse country

Re: PHP SESSION

Postby Piers » Thu Jan 31, 2008 9:36 am

It's a lot of data to store in what is essentially a cookie...
Image

nos

Re: PHP SESSION

Postby nos » Thu Jan 31, 2008 6:44 pm

yes i know, thats what im thinking to.

so the question is will it reduce server load or increase.


Return to “The Buddabudda Stats system”

Who is online

Users browsing this forum: CommonCrawl [Bot] and 0 guests