Magento Forum

   
Magento Session connection from outside magento to magento .phtml
 
verzet
Jr. Member
 
Total Posts:  4
Joined:  2012-09-12
 

Hello , i am trying to create a Age verification page from an outside index page with a Magento session, store the session in magento and then verify if the session is in there or redirect back.
This works to a certain point . I used the coding to create a Magento session in an NON magento php file :

if($age $minAge){
            
require 'magento/app/Mage.php';
            
$mageRunCode = isset ( $_SERVER ['MAGE_RUN_CODE') ? $_SERVER ['MAGE_RUN_CODE''';
            
$mageRunType = isset ( $_SERVER ['MAGE_RUN_TYPE') ? $_SERVER ['MAGE_RUN_TYPE''store';
            
$app Mage::app $mageRunCode$mageRunType );
            
$core_session Mage::getSingleton 'core/session', array ('name' => 'frontend' ) );
            
$write Mage::getSingleton 'core/resource' )->getConnection 'core_write' );
            
$url Mage::getUrl '*/*/*', array ('_current' => true ) );
            
$core_session->setAge('age');
            
header("location: http://vodkastorebe.webhosting.be/magento/home");
        
else {
                header
("location: error.php");}

the session existed by trying :

$test Mage::getSingleton('core/session')->getAge();
echo(
$test);

This worked, and i got the echo : “age” back on the screen.

BUT here the issue when i use this code INSIDE magento .phtml page

$test '';
$test Mage::getSingleton('core/session')->getAge();
echo (
$test);

What am i doing wrong?
Thanks alot for any help.

 
Magento Community Magento Community
Magento Community
Magento Community
 
verzet
Jr. Member
 
Total Posts:  4
Joined:  2012-09-12
 

Still didn’t get any help but will update some info on the subject.

I know i get the echo from the session i create anywhere i paste that echo code.
I have tried some IF statements to either go back to the 1st page or if the session created is ‘age’ to go to the magento page.

Now according to the IF statements i make INSIDE the 3columns.phtml file
when i put like header(’location: http://*****.com’; for example that redirect when the echo is correct
then i make an infinite loop because he goes over that if statement again.
when i tried include(’3columns.phtml’); i got blank page.

Im starting to believe maby i have to work with a controller?? i dont know how and if i do it has to be a controller so people cannot go to any pagelink without them had created the session on the index page. Since this is still a age verifying script.

Please someone must know, all that combined IQ lol

Thx in advance

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top