Hi
In server validation I have the following code:
in my file upload1.php I have the following code:
The $_SESSION['username']; is empty. Why?
In server validation I have the following code:
session_start();
$_SESSION['username']=$username;
global $mainframe;
$mainframe->redirect("uploads/upload1.php");
in my file upload1.php I have the following code:
<?php
session_start();
echo " A sessão é ";
echo $_SESSION['username'];
The $_SESSION['username']; is empty. Why?
Hi,
It might be that Joomla implements it's own session handler (defaults to using the sql-database storage), while your standalone php-script uses the php-default handler. Have a look at the chrono_verification.php script for hints on how you can access data stored in the session storage by Joomla in your standalone script.
/Fredrik
It might be that Joomla implements it's own session handler (defaults to using the sql-database storage), while your standalone php-script uses the php-default handler. Have a look at the chrono_verification.php script for hints on how you can access data stored in the session storage by Joomla in your standalone script.
/Fredrik
Hi Fredrik
I think you are in the right track. Joomla creates is session variables and when I execute other php files outside joomla the session variables are empty.
I think you are in the right track. Joomla creates is session variables and when I execute other php files outside joomla the session variables are empty.
Here is my solution to this problem.
I used jumi (and made some upload code) and all works fine now because I don't have to exit form Joomla.
wrong answer - Sorry
I have to exit from joomla with my script for upload
Lost $_SESSION['username'] value
Not solved yet
I used jumi (and made some upload code) and all works fine now because I don't have to exit form Joomla.
wrong answer - Sorry
I have to exit from joomla with my script for upload
<?php
session_start();
//$target_path = "uploads/";
$cam= $_SESSION['username'];
$target_path = $cam."/";
echo $target_path;
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "The file ". basename( $_FILES['uploadedfile']['name']).
" has been uploaded";
} else{
echo "There was an error uploading the file, please try again!";
}
?>
Lost $_SESSION['username'] value
Not solved yet
Hi,
The lines from chrono_verification.php that you need, are the following:
/Fredrik
The lines from chrono_verification.php that you need, are the following:
define( '_JEXEC', 1 );
/* Probably have to modify this line; make sure it points to the directory where your Joomla-installation resides
*/
define( 'JPATH_BASE', realpath(dirname(__FILE__).'/../..' ));
define( 'DS', DIRECTORY_SEPARATOR );
require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );
$mainframe =& JFactory::getApplication('site');
$mainframe->initialise();
$session =& JFactory::getSession();
/* Read data from the session storage;
* Make sure you use $session->set() when you save the value in the session storage
*/
$cam = $session->get('username');
/Fredrik
This topic is locked and no more replies can be posted.