hey all! i have a question with gallery session vars

ikaush

Joined: 2004-04-10
Posts: 8
Posted: Tue, 2005-09-06 21:27

is it possible to add a var to the gallery session?

i've tried using $_SESSION['bla'] = 'aaa';

but i guess that it isnt the way..

please tell me how.. i want to add one var..

Thank you!

 
notgoddess
notgoddess's picture

Joined: 2005-04-03
Posts: 178
Posted: Wed, 2005-09-07 12:34

Actually that should work, but are you doing it on a page where the session is active?
You need to include Gallery's init page and start the session:

include_once('init.php'); // for file in Gallery basedir adjust accordingly.
session_start();

$_SESSION['myvar'] = 'foobar';

You might have to do: session_write_close(); on your script to close/save the session if you end the script early (usually not needed tho).

Ng

 
ikaush

Joined: 2004-04-10
Posts: 8
Posted: Wed, 2005-09-07 19:51

i've wrote my vars as
$gallery->session->VarName = "foobar";

my new question is how do i add a function as
$gallery->session->clear_special_vars();

i mean where do i need to add the function?..

Thanks alot!

 
notgoddess
notgoddess's picture

Joined: 2005-04-03
Posts: 178
Posted: Wed, 2005-09-07 19:57

To my knowledge you can't add a function to a session variable-you'd have to have a check at whereever you use those variables and unset them when you are done with them.

Ng

 
saul11

Joined: 2005-10-04
Posts: 109
Posted: Wed, 2007-04-25 10:29

wooops: this is gallery2, I don't think it works in g1

I just found out that working with gallery's session object can be done like this:

setting a variable
$session =& $gallery->getSession();
$session->put('yourVariable', $yourVariable);

and to get it
$session =& $gallery->getSession();
$yourVariable = $session->get('yourVariable');