News:

Looking for documentation? Take a look on our wiki

Main Menu

pass on variables from joomla to VM2

Started by fabvincent, December 09, 2013, 10:59:10 AM

Previous topic - Next topic

fabvincent

Hi all,
I implemented a tiny code on the default.php page of my category so I can have a breadcrumb. Everything's ok but I need to pass on a session variable form my index page (joomla 2.5) to the default page (Virtuemart 2).
I've been using a simple $_SESSION in between the two of them but they don't seem to connect. so my variable from joomla stays blank on the default.php page. I know the problem has been addressed before and quite a long time ago (found a 2007 subject). Is there any way to pass on the variables? Should I use a $_GLOBAL?
Thanks in advance.

GJC Web Design

does this not work?

$session = JFactory::getSession();
$myvar = $session->get('myvar');
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

Milbo

#2
Quote from: fabvincent on December 09, 2013, 10:59:10 AM
Hi all,
I implemented a tiny code on the default.php page of my category so I can have a breadcrumb.
Ehrm strange, breadcrumbs are native there.

Quote from: fabvincent on December 09, 2013, 10:59:10 AM
Everything's ok but I need to pass on a session variable form my index page (joomla 2.5) to the default page (Virtuemart 2).
What? You cannot pass a session variable between two pages on the same server. they HAVE THE SAME SESSION!

Quote from: fabvincent on December 09, 2013, 10:59:10 AM
I've been using a simple $_SESSION
If you are in joomla, you maybe should use the stuff which joomla gives you. Else you can destroy your session, which makes your joomla installation unusable.

Quote from: fabvincent on December 09, 2013, 10:59:10 AM
in between the two of them but they don't seem to connect.
Please learn first the basics about what the session is. http://php.net/manual/en/intro.session.php

Quote from: fabvincent on December 09, 2013, 10:59:10 AM
Should I use a $_GLOBAL?
Thanks in advance.

Session IS within the $_GLOBAL

and this is the way todo it (regardless in which component of joomla)


$session = JFactory::getSession();
$previousValue = $session->set('myValue', $value,'myNameSpace');


and you get it like this

$session = JFactory::getSession();
$value = $session->get('myValue', myDefault,'myNameSpace');
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/