Re: Perform maths based on a number in a text file [message #183808 is a reply to message #183747] |
Thu, 21 November 2013 03:10 |
Denis McMahon
Messages: 634 Registered: September 2010
Karma:
|
Senior Member |
|
|
On Mon, 18 Nov 2013 01:23:06 -0800, drkirkby wrote:
> I'm tyring to simplify the design of a web site which uses PHP, and hope
> someone can help me. Basically I want to store a number
> Any thoughts?
Yes, why do you want to store the data in a text file?
Is it possible that different users of your web site might have different
numbers at the same time?
What happens if you have 1 text file and 2 users have different numbers?
Do you want to store the number for a short period (seconds, minutes,
maybe hours) or for longer periods (days, weeks, months)?
If you're trying to store user specific math data for a short period, the
best storage method is probably to use the php session mechanism. This
allows you to associate a set of data variables with each user identified
by a session cookie on their browser (the cookie is basically a random
number that you generate once when a user starts a session).
You then have a php superglobal array called $_SESSION which can then
contain any named variables you wish on a per user basis.
This may be an over-simplification of php sessions, for more information
look at the session functions especially session_start() in the php
documentation.
http://us1.php.net/session_start
--
Denis McMahon, denismfmcmahon(at)gmail(dot)com
|
|
|