VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: fabvincent on December 09, 2013, 10:59:10 AM

Title: pass on variables from joomla to VM2
Post by: 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. 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.
Title: Re: pass on variables from joomla to VM2
Post by: GJC Web Design on December 09, 2013, 12:45:00 PM
does this not work?

$session = JFactory::getSession();
$myvar = $session->get('myvar');
Title: Re: pass on variables from joomla to VM2
Post by: Milbo on December 09, 2013, 13:03:36 PM
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');