Topic: Passing a resource as a session variable?

Hey all,

I want to pass a pg resource as a session variable, however when I try and do this in the conventional fashion the session variable has an integer value and cannot be passed to usual resource handling functions.

$result = pg_query($db_conn, $query);
$_SESSION['res'] = $result;

//in a diff script (same session)
pg_fetch_array($_SESSION['res'], NULL, PGSQL_ASSOC);
^--- fails because the session variable evaluates as an integer and not a postgres resource.

Any thoughts?

Re: Passing a resource as a session variable?

you can't store any ressources in a SESSION variable. The ressouces are lost when the php process dies, because it closes the DB connection. You can however store the values in a session.

Re: Passing a resource as a session variable?

Thanks for the info q_no, sadly I discovered that yesterday and thus have changed my approach.  I wanted to pass the resource to the fn to avoid firing off the query twice but now im just executing the query twice!

- N