Author Topic: pass on variables from joomla to VM2  (Read 963 times)

fabvincent

  • Beginner
  • *
  • Posts: 33
pass on variables from joomla to VM2
« 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.

GJC Web Design

  • 3rd party VirtueMart Developer
  • Super Hero
  • *
  • Posts: 8891
  • Virtuemart, Joomla & php developer
    • GJC Web Design
  • VirtueMart Version: 3.4.2
Re: pass on variables from joomla to VM2
« Reply #1 on: December 09, 2013, 12:45:00 pm »
does this not work?

$session = JFactory::getSession();
$myvar = $session->get('myvar');
GJC Web Design
VirtueMart and Joomla Developers - php developers http://www.gjcwebdesign.com
VM3 AusPost Shipping Plugin - e-go Shipping Plugin - VM3 Postcode Shipping Plugin - Radius Shipping Plugin - VM3 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
http://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 9853
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: pass on variables from joomla to VM2
« Reply #2 on: December 09, 2013, 13:03:36 pm »
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.

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!

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.

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

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)

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

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