B
B
bamond2014-07-18 13:18:32
PHP
bamond, 2014-07-18 13:18:32

Session + joomla - what's the problem?

Good afternoon.
Joomla.
There is a script that displays the captcha.
Please help me sort out the sessions in this situation.
1) if it's easy to do

//////////captcha.php
session_start();
$rand = 15;
$_SESSION["rand"] = $rand;

and on the main form do
//////////form.php
session_start();
<img src = "QAmodule/captcha.php">
var_dump($_SESSION['rand']);

then we get null.
If done through
//////////captcha.php
define('BASE_PATH',$_SERVER["DOCUMENT_ROOT"]);
require_once BASE_PATH.'/includes/defines.php';
require_once BASE_PATH.'/includes/framework.php';
define( '_JEXEC', 1 )
$rand = 15;
$session = JFactory::getSession();
$session->set( 'randStr', $rand );

then the captcha is not displayed at all =)
Please tell me what can be done here and how to pass the $rand value to form.php?
Thank you!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman Sokharev, 2014-07-18
@greabock

Joomla and many other engines use their own session mechanism, not related to the $_SESSION array. Use the Joomla API to create sessions.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question