RE: [PHP-DB] Re: Using $_SESSION array for large number of variables. Any recommendations?
| From: | Peter Lovatt | Date: | Mon, 26 Apr 2004 00:59:57 +0000 |
| Subject: | RE: [PHP-DB] Re: Using $_SESSION array for large number of variables. Any recommendations? | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-34085@lists.php.net to get a copy of this message | ||
Hi,
I would suggest a mysql table for the data. For large amounts it is probably
more efficient - not sure how much resource is needed to manage 100K pieces
of information using $_SESSION, but an indexed mysql table is probably much
quicker.
table
CREATE TABLE
session_data (
userID VARCHAR( 20 ) NOT NULL ,
var_name VARCHAR( 100 ) NOT NULL ,
var_data VARCHAR( 250 ) NOT NULL ,
PRIMARY KEY ( userID , var_name )
);
you then retrieve the data at the beginning of each page request.
This is also persistent, so it will be there for as long as needed. If you
have a login system this also allows the user to switch machines or
browsers - $_SESSION is linked to the browser.
From experience this works well.
hth
Peter
-----------------------------------------------
Excellence in internet and open source software
-----------------------------------------------
Sunmaia
Birmingham
UK
www.sunmaia.net
tel : 0121-242-1473
fax : 0870 7621758
International +44-121-242-1473
-----------------------------------------------
> -----Original Message-----
> From: Jimmy Brock [mailto:jimmybrock@yahoo.com]
> Sent: 26 April 2004 00:48
> To: php-db@lists.php.net
> Subject: [PHP-DB] Re: Using $_SESSION array for large number of
> variables. Any recommendations?
>
>
> I would recommend cookies, not session.
>
> Cookies are stored on the users machine, whereas session data is stored on
> the server. If you have a power failure or have to reboot the
> server session
> data will be lost -- since session data is stored in memory.
>
> "Ross Honniball" <ross@bookshop.jcu.edu.au> wrote in message
> news:6.0.0.22.1.20040425182335.01c17e40@bookshop2.jcu.edu.au...
> > Hi all,
> >
> > System : Windows XP / Apache / MySql / PHP
> >
> > I'm considering using session variables to store a large amount of data.
> > How much is 'large'? To be honest, I have no idea at this point - very
> > early days.
> >
> > For arguments sake, lets say the system consisted of 100 users who will
> all
> > store between them say 1000 different variables and objects for a period
> of
> > 1 or 2 days.
> >
> > In a nutshell, reason for storing this info is to save the state of php
> > programs.
> >
> > Is this approach advisable, or are there limits / other considerations
> when
> > using session variables?
> >
> > I would greatly appreciate peoples comments on potential
> problems pursuing
> > this approach from anyone with extensive experience using session vars.
> >
> > Thanks ... Ross
> >
> > . Ross Honniball JCU Bookshop Cairns Supervisor
> > . James Cook Uni, McGreggor Rd, Smithfield, Qld. 4878, Australia
> > . Ph:07.4042.1157 Fx:07.4042.1158 Em:ross@bookshop.jcu.edu.au
> > . There are no problems. Only solutions.
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>