Announcement

#1 2013-07-29 20:00:46

osyris
Member
2013-07-29
12

access other session variables.

Hi Guys,

I really worked on this a lot and it's driving me nuts, cause I can't figure it out.
Of course I also tried searching, but unsuccessfully.

This is the situation:
piwigo runs in a subdirectory of my site (/gallery).
On the main Site I have some other stuff running, where I also use a session.
Now what I want to do is be able to have access to the other session variables from inside piwigo.
It's okay if they are read only, I just need to know them.

And there's just no chance.
I tried setting the session name in my other scripts to the same as in piwigo (default pwg_id).
No success.

The closest I came to achieving what I want is this:
Right at the beginning of the index.php I added this

Code:

session_start();
$MY_SESSION = $_SESSION;
session_write_close();

And then after the regular pwigo session init integrate it back into the session variable.

Code:

$_SESSION["MY_SESSION_VARS"] = $MY_SESSION;

If I print_r the Session variable right after this, it looks okay and quite how I imagine it.
The problem though is that this breaks the login (and proably brings along some other problems).


Please give me a hint where and how I should implement this.

thank you,
Jan

Last edited by osyris (2013-07-29 20:04:04)

Offline

 

#2 2013-07-29 20:11:18

mistic100
Former Piwigo Team
Lyon (FR)
2008-09-27
3277

Re: access other session variables.

I think the problem is
session_set_cookie_params(0, cookie_path());
in include/functions_sessions.inc.php line 72
which somehow block access to other session vars

you can try $conf['session_save_handler']=null;
this will prevent Piwigo using the database to store session vars and setting the cookie path

Offline

 

#3 2013-07-29 20:20:32

osyris
Member
2013-07-29
12

Re: access other session variables.

Awesome!

This actually seems to be working!
I changed Line 402 of config_default.inc.php to this:

Code:

$conf['session_save_handler'] = null;

Does this have any drawbacks you can think of?
Why was it set to "db" in the first place?

Thank you for your quick reply!

regards,
Jan

Offline

 

#4 2013-07-29 20:26:28

mistic100
Former Piwigo Team
Lyon (FR)
2008-09-27
3277

Re: access other session variables.

damnit ! don't change config_default ! it must only contain default values

use local files editor

Offline

 

#5 2013-07-29 20:34:30

osyris
Member
2013-07-29
12

Re: access other session variables.

Hi,

Sorry, no need to get angry :-).
I just changed it the first place I found it to test out if it even works...

Can you please also answer my other questions?

Does this fix have any drawbacks?
I'm sure you had a reason for setting the value to "db"?

Regards,
Jan

Offline

 

#6 2013-07-29 20:36:37

mistic100
Former Piwigo Team
Lyon (FR)
2008-09-27
3277

Re: access other session variables.

I don't know (for both)

Offline

 

#7 2013-07-29 20:39:50

osyris
Member
2013-07-29
12

Re: access other session variables.

I see.

Thanks anyway. This helped me a lot!
I'll write if an issue arises.

best regards,
Jan

Offline

 

#8 2013-07-29 21:47:14

flop25
Piwigo Team
2006-07-06
7037

Re: access other session variables.

Don't forget to search in the forum/doc even if we are answering on your thread

The default value is db, due to security reason : http://piwigo.org/dev/changeset/1004/tr … lt.inc.php and also to be less server dependent (files permissions ...)


To get a better help : Politeness like Hello-A link-Your past actions precisely described
Check my extensions : more than 30 available
who I am and what I do : http://fr.gravatar.com/flop25
My gallery : an illustration of how to integrate Piwigo in your website

Offline

 

#9 2013-07-29 23:11:14

mistic100
Former Piwigo Team
Lyon (FR)
2008-09-27
3277

Re: access other session variables.

I'm really not sure these reasons are still "valid"

Offline

 

#10 2013-07-30 11:43:10

osyris
Member
2013-07-29
12

Re: access other session variables.

Everything seems to work fine, except one thing.
I have the community plugin installed and when I try to upload a picture as a normal user, using the flash uploader I get an HTTP Error (401) And can't upload the file.
If I upload it using the regular direct upload everything works.

My guess is that the uploadify.php file uses the session variable to "tell" piwigo, hey - there are some uploaded files to process. And something gets lost somewhere.

The error disappears, when I set the conf value back to "db".

Any ideas?

regards,
Jan


Exact error message: "2013-05-24 19.22.54.jpg, HTTP Error (401)"

Offline

 

#11 2013-08-12 17:30:28

osyris
Member
2013-07-29
12

Re: access other session variables.

I sadly still have not found a solution for this :(.

Any ideas, anyone?

Offline

 

#12 2013-08-12 17:39:00

flop25
Piwigo Team
2006-07-06
7037

Re: access other session variables.

for the 401? Well use the html forms, or any of the others way to upload (by ftp, by software etc)


To get a better help : Politeness like Hello-A link-Your past actions precisely described
Check my extensions : more than 30 available
who I am and what I do : http://fr.gravatar.com/flop25
My gallery : an illustration of how to integrate Piwigo in your website

Offline

 

#13 2013-08-12 17:41:45

osyris
Member
2013-07-29
12

Re: access other session variables.

Hi flop,

thank you for your reply.
I'm afraid that's not really an option in this case, as I am building a (closed) community site.
So users should be able to upload pictures.
And using the html way is just not practical for higher quantities of images...

So I'll need to get this issue resolved somehow.

lg J

Offline

 

#14 2013-08-12 18:05:07

flop25
Piwigo Team
2006-07-06
7037

Re: access other session variables.

so get the sessions through the db


To get a better help : Politeness like Hello-A link-Your past actions precisely described
Check my extensions : more than 30 available
who I am and what I do : http://fr.gravatar.com/flop25
My gallery : an illustration of how to integrate Piwigo in your website

Offline

 

#15 2013-08-12 18:10:26

osyris
Member
2013-07-29
12

Re: access other session variables.

...
really?

I mean I appreciate the help and all, but if I do that I'll be back to square one.
As you can read above disabling the session through the db was the only way I could get piwigo to "see" my own session variables.

So I either have to find a way to get a hold of my "other" session when using the db option for the piwigo session or I need to fix the uploadify error when deactivating it.

I realize that you guys must be incredibly busy creating such a wonderful and complex software, but I'd like to find solutions not work-arounds.

thank you and regards,
Jan

Offline

 

Board footer

Powered by FluxBB

github twitter newsletter Donate Piwigo.org © 2002-2024 · Contact