Forum Moderators: coopster

Message Too Old, No Replies

Preserve session

Preserve an object handle between pages in a session.

         

netbuddy

10:09 am on Jun 29, 2008 (gmt 0)

10+ Year Member



I am currently looking for a way of reserving session data between pages.

The problem I have is how to store into a session variable the handle for $ftp which is what I use as the ftp handle and this is what I need to preserve in a session variable.

$ftp = ftp_connect("myserver.com");

I have tried to use

$_SESSION['ftp'] = serialize($ftp);

and every time I try to use it the page locks up and eventually I get a server 500 error.

Any suggestions on how or what I should do in this situation?

The main purpose of the function I wrote works perfectly fine, it achieves its main objective however, its the passing of the handle in a session that its not happy with.

vincevincevince

12:07 pm on Jun 29, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You won't be able to keep an FTP handle in the session; you need to open the FTP handle every page load. A more practical way of holding open FTP between page loads is by using shell_exec() to talk to a more persistent command-line FTP system.

netbuddy

1:39 pm on Jun 29, 2008 (gmt 0)

10+ Year Member



Thx.

It is odd because the PHP site reckons that this is possible when you serialize objects.

vincevincevince

1:42 pm on Jun 29, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can serialize objects; but not FTP, file or database handles. They are destroyed as the page closes.

vincevincevince

2:39 pm on Jun 29, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Relevant thread: [webmasterworld.com...]

netbuddy

9:33 pm on Jul 16, 2008 (gmt 0)

10+ Year Member



Thanks for the input.