I have been using fsockopen() in a function in a class. I am able to pass all the objects in a class to another page except the fsockopen () value. I have put the values of objects from the output print_r() as below
main pages Class objects
Cisco Object
(
[_hostname:private] => 10.10.1.49
[_password:private] => cisco123
[_username:private] => cisco
[_connection:private] => Resource id #3
[_data:private] => R3#
[_timeout:private] => 3
[_prompt:private] => #
)
Class values transfred to another page
Cisco Object
(
[_hostname:private] => 10.10.1.49
[_password:private] => cisco123
[_username:private] => cisco
[_connection:private] => 0
[_data:private] => R3#
[_timeout:private] => 3
[_prompt:private] => #
)
In all other pages the [_connection:private] value is resetting to 0. I have treid using class Cisco declaring class as SESSION. (session_register('cisco');) and global, but no hope.
Part of my code is
Expand|Select|Wrap|Line Numbers
- class Cisco
- {
- private $_hostname;
- private $_password;
- private $_username;
- private $_connection;
- private $_data;
- private $_timeout;
- private $_prompt;
- public function __construct($hostname, $password, $username, $timeout = 3)
- {
- $this->_hostname = $hostname;
- $this->_password = $password;
- $this->_username = $username;
- $this->_timeout = $timeout;
- }
- public function connect()
- {
- $this->_connection = @fsockopen($this->_hostname, 23, $errno, $errstr, $this->_timeout);
- // code continues ....