Forums

How to write in $_SESSION ?

Tigunn 19 Feb, 2016
Hello,
I have a website with Joomla 3.4.8, with the extension Chronoforms5 RC6, where I developed a form.
In the onsubmit event, I
- A multi-page element (it is a form several pages which works fine)
- An element Custom code
- A redirection element to a PHP page, test.php, (an online payment gateway of)
I would like, using the element Custom code, insert a PHP code to write in $ _SESSION.
So I wrote:
session_start();
$_SESSION['test']='oui';
session_write_close();

and retrieve information for $ _SESSION in php test.php file.
Test.php The file contains:
session_start();
echo '<pre>';
print_r($_SESSION);
echo '</pre>';

and nothing is displayed.

I try the solution below:
http://stackoverflow.com/questions/9459430/include-jfactory-class-in-an-external-php-file-joomla
Doesn't work

I'm interested in any solution ...
GreyHead 19 Feb, 2016
Hi Tigunn,

Is this external file in the same folder as your site? If so, your code or something similar should work. If not then the $_SESSION data won't be available.

What is the payment gateway file that you are using in test.php?

Bob
Tigunn 22 Feb, 2016
Hi GreyHead,
test.php is in [root site folder]/[gateway]/ the same folder of my site.
test.php is a simple script to show data from $_session. nothing more.
GreyHead 22 Feb, 2016
Hi Tigunn,

Have you added <?php ?> tags?

What do you actually need to do here?

Bob
Tigunn 22 Feb, 2016
yes i added <?php ?> tags.
My goal:
I want to export my form's data (amount, currency, ...) in a php file wich will call gateway's API.
Use $ _session seemed to be the easiest method.
What do you think?
GreyHead 22 Feb, 2016
Hi Tigunn,

The easiest is to do it directly from ChronoForms - depending on the gateway you can use the cURL action; the ReDirect action or Custom code, possibly using an API library for the gateway.

Bob
Tigunn 22 Feb, 2016
How to use Redirect Action :
I have the url: http://[my site]/[gateway folder]/test.php
The extra params:
amount=montant_cmd

$form->data['montant_cmd'] is define (=180) but in test.php i try :
echo '<pre>';
print_r($_SESSION);
echo '</pre>';
echo '<pre>';
print_r($_POST);
echo '</pre>';
echo '<pre>';
print_r($_GET);
echo '</pre>';
exit;
and nothing?
how to use variables amount?
Tigunn 22 Feb, 2016
Answer
ok, i correct:
with redirect Action, variables are in $_GET. It's not good idea for payment gateway.

So, i tried to use a custom code using API library for the gateway; and it's working 😀 .
Thanks for your help.
This topic is locked and no more replies can be posted.

VPS & Email Hosting 20% discount
hostinger