views:

29

answers:

3

i hava a class that hold a list for each request but each request the list is empty again what can i do to make it live

here is my class , i want the list to hold values from previews requests (yes each request i'm settings a value there )

class Sessions{
    private static $list     = array();
    ....
    .....
}
+2  A: 

It's supposed to be like that. Every request is independent and restarts whole program. Use sessions to store data between requests.

porneL
can i store objects in sessions ?
shay
yes you can, as long they are serializable:http://www.php.net/manual/en/language.oop5.serialization.php
Mchl
thank u i will try that latter on ,
shay
+1  A: 

'static' variables do not survive until the next request. You should either use $_SESSION to store custom data per user, or save it to some file/database/...

o_O Tync
+1  A: 

If you want data to persist for each request from the same user you have to use session. If you want data to persist for every user you have to store them in a file or in database.

Nat