| 
	
 | 
 Posted by Ian Hobson on 09/06/07 10:49 
eliran wrote: 
> On Sep 5, 11:16 pm, Ian Hobson <ian.hob...@ntlworld.com> wrote: 
>> eliran wrote: 
>>> I am new user in PHP 
>>> is there in PHP a mechanizm to keep vaiables (or arrays) 
>>> so on each new client request 
>>> I can see previous values I kept in previous client request ? 
>>> something like internal 'database' ? 
>>> rgrds 
>>> EL 
>> Yes - they are called session variables. See CXLIX. Session Handling 
>> Functions in the manual :) 
>> 
>> You have to start the session (e.g. by calling session_start();) which 
>> creates the super global $_SESSION and populates it with the variables 
>> your saved there from last visit by this browser. 
>> 
>> Note - the session is controlled by a cookie, so it refers to the 
>> browser invocation, not a window. 
>> 
>> If you want something stored that is unique to a window, it - or an 
>> identifier so you can get it back - has to go into a hidden field in the 
>> form. 
>> 
>> Warning - You should (IMHO) turn off the option in php.ini that permits 
>> sessions to be controlled by the URL, because it is too easy for 
>> sessions to be hi-jacked when the URL is bookmarked or copied. This will 
>> mean that the session mechanism will only work if your visitors haven't 
>> turned off cookies completely. 
>> 
>> Regards 
>> 
>> Ian 
>  
> Ian, 
>  
> 1. 
> the SESSION global may help. 
> to handle the client session ID + it's variables. 
> 
Nope - the session ID is handled automatically. Data you place into  
$_SESSION is recreated when (if) your visitor returns. 
 
> I mean something just for server variables handling, no connection to 
> clients 
> so is it possible to handle server only global variables 
> like to save last used tcp port or calculate some total entries 
> and of course much more. 
>  
I think the way to get the stats you want is to log the information to a  
(the?) log file, and scan that when required. 
 
If you want something like a visitor counter, you will have to store  
that yourself in a file - load, update and store as required. Don't  
forget to lock the file while you do this - Apache and php are  
multi-threading, and you could find your changes over-written by another  
visitor's thread. 
 
Regards 
 
Ian
 
  
Navigation:
[Reply to this message] 
 |