Announcement

#1 2013-07-10 01:08:07

jessepunter
Member
England
2013-04-23
44

Session variables in Piwigo

Hi all,

I wonder if anyone can help me or point me in the right direction. I have used Piwigo to develop a greetings card website for my partner and I love the features it offers. I've used the Stripped theme as a starting point and the sight now looks great.

However, I have one little problem. I use a Session variable to store the array for the shopping basket, and to create the View cart and Checkout windows I've used Additional Pages plugin.

This is where the problem begins. I have successfully started a new session for my cart windows but I ideally want to be able to show a cart icon with number of items shown against it in the header section of each window. I've used the header region in the Options menu to populate the header but I cannot access my new $_SESSION array to show the contents on any window but the cart ones I've developed.

My question is, how can I implement Session variables that will be accessible throughout the Piwigo site? I assume the main one used is 'pwg_id' so I don't mind piggy backing off that one if required, but anyone got any ideas how Piwigo uses session variables and how to reference them throughout the site?

Many thanks in advance for any help offered!

Cheers,
Simon.


I'm no expert, I'm basically a beginner with an alter ego!
My sites:
My First Piwigo Site
My Hobby Site

Offline

 

#2 2013-07-10 01:36:22

flop25
Piwigo Team
2006-07-06
6895

Re: Session variables in Piwigo

Hi
As a quick answer from my midnight bed, search "session" in Piwigoffiles to find the piwigo functions to set and use session variable


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

 

#3 2013-07-10 12:39:24

jessepunter
Member
England
2013-04-23
44

Re: Session variables in Piwigo

Thanks flop25, I'll look at that when I get a break from work!

Cheers,
Simon.


I'm no expert, I'm basically a beginner with an alter ego!
My sites:
My First Piwigo Site
My Hobby Site

Offline

 

#4 2013-07-10 14:21:14

flop25
Piwigo Team
2006-07-06
6895

Re: Session variables in Piwigo


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

 

#5 2013-07-13 19:47:14

jessepunter
Member
England
2013-04-23
44

Re: Session variables in Piwigo

Thanks for the info flop25!

Unfortunately I don't think I'll be able to use these functions as I have a Session array (maybe I should have mentioned that?!) so I don't think I'll be able to store that in the database without either splitting out each separate variable within the array or changing it to store each entry as a comma delimited string?

I do have my own $_SESSION['shop'] array defined and it works well in my shopping cart windows, but I'd love to be able to access it throughout my piwigo website.

Really appreciate your input flop25, so thanks!


I'm no expert, I'm basically a beginner with an alter ego!
My sites:
My First Piwigo Site
My Hobby Site

Offline

 

#6 2013-07-13 19:56:00

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

Re: Session variables in Piwigo

you could juste serialize your array

pwg_set_session_var('key', serialize($some_array));
$some_array = unserialize(pwg_get_session_var('key'));

Offline

 

#7 2013-07-15 10:44:32

jessepunter
Member
England
2013-04-23
44

Re: Session variables in Piwigo

Thanks mistic100, I'll give that a go.

I actually managed to get it to work with a combination of Javascript and php, setting a Javascript variable with the relevant value(s) of my array from within the php code. Seems to work nicely, but like I said I'd prefer to use the piwigo session, so I'll look at your solution too!

Thanks again chaps!


I'm no expert, I'm basically a beginner with an alter ego!
My sites:
My First Piwigo Site
My Hobby Site

Offline

 

Board footer

Powered by FluxBB

github twitter facebook google+ newsletter Donate Piwigo.org © 2002-2019 · Contact