dandanbsb Posted February 15, 2007 Share Posted February 15, 2007 Hi all Im trying to find the solution for my problem for a while and cant find it Here is whats happening: i have a regular class named phoneVO with three attributes, and with the respectives getters and setters. Im using php and ajax to add phonesVO objects into the session, like this: function addPhone($ddd,$number,$type){ $phones_array = $_SESSION["userPhones"]; $phoneVO = new phoneVO(); $phoneVO ->setDdd($ddd); $phoneVO ->setTelephone($number); $phoneVO ->setType($type); $phones_array[count($phones_array)] = $phoneVO; $_SESSION["userPhones"] = $phones_array; return $phones_array; } so, each time the user clicks on a button add phone, i will call this function(with others to make a html etc) with ajax and add a phone to the user with the parameters passed. The problem is that, as soon as i add the object to the session, it gets destructed.(i added a line on the __destruct function at phoneVO to log the time it is destructed). How can i tell PhP to NOT destruct this objects while at session, or something like this?? Any ideas that can solve this?? Tnx 4 ur time bye Link to comment https://forums.phpfreaks.com/topic/38674-help-with-php-objects-being-destructed-in-sessionwith-ajax/ Share on other sites More sharing options...
TreeNode Posted February 15, 2007 Share Posted February 15, 2007 Does your called AJAX file have session_start(); at the top as well? Link to comment https://forums.phpfreaks.com/topic/38674-help-with-php-objects-being-destructed-in-sessionwith-ajax/#findComment-185737 Share on other sites More sharing options...
dandanbsb Posted February 15, 2007 Author Share Posted February 15, 2007 By the way, im using the include_once to that function php page after session_start(); If i put it before it works ;/ Any1 knows why? tnx Link to comment https://forums.phpfreaks.com/topic/38674-help-with-php-objects-being-destructed-in-sessionwith-ajax/#findComment-185740 Share on other sites More sharing options...
nloding Posted February 15, 2007 Share Posted February 15, 2007 Sounds like TreeNode is right ... put session_start() at the top of any file called via Ajax. If that works, please post back. I will need to know this myself shortly! Link to comment https://forums.phpfreaks.com/topic/38674-help-with-php-objects-being-destructed-in-sessionwith-ajax/#findComment-185793 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.