1

Possible Duplicate:
Can't pass mysqli connection in session in php

I'm trying to keep an ssh connection alive through the whole browsing process of my php web application. Basically I have a login form, whose parameters (login and passowrd) are passed to the ssh2_auth_password() function. I simply try to have the resource associated to ssh2_connect() stored into $_SESSION, so that it can be used in another web page where the user gets redirected (if connection is succesful). What it happens, instead, is that the ssh connection seems to die just after the login page has been left (i.e. after the redirection takes place). My question is: is there any way to store the handler of an ssh connection into a session variable? If so, can you help me? Thank you so much, Alex

Community
  • 1
  • 1
  • 1
    A session is a cookie server side (eg a file), its like saying how can I store a ssh connection resource in the users browser in a cookie. – Lawrence Cherone Jul 11 '12 at 12:22
  • @LawrenceCherone: The session **data** is stored on the server. The only thing that is passed to the user is an **identifier** so that the server knows which session belongs to that user. Storing a connection resource on the server is plausible, however the issue is, that different PHP/webserver processes may handle each individual request. You cannot pass an open resource between processes like this. – Leigh Jul 11 '12 at 12:25

2 Answers2

3

You need to read the Session documentation

I'll quote the relevant part for you.

Warning

Because session data is serialized, resource variables cannot be stored in the session.

Community
  • 1
  • 1
Leigh
  • 12,859
  • 3
  • 39
  • 60
0

You could try phpseclib, a pure PHP SSH implementation, and replace fsockopen with pfsockopen.