I want to dynamically populate data in Facebook open tags. For this, I need to pass a variable from my controller file to a file which is outside the CI model. How to do this?
public function index()
{
$data['clients'] = $this->qua_model->list_clients();
$data['clientst'] = $this->qua_model->list_clientst();
$id = $this->uri->segment(3);
//GET RECORD BY ID
$data['result']=$this->qua_model->get_record_by_id($id);
// print_r($data['result']);
$data['url']= urlencode(base_url().'intermediate.php?data=$result');
// print_r($data['url']);
// return;
//echo $data['url'];
//exit();
//$data['url'] = base_url().'Testimonial';
$this->load->view("header",$data);
$this->load->view("testimonial",$data);
$this->load->view("footer");
}
The above code is the index function of my controller. I want to pass the variable $result to intermediate.php page.
Below is the intermediate.php page.
<!DOCTYPE html>
<html>
<head>
<!--<meta property="fb:app_id" content="535219850163370" />
<meta property="og:site_name" content="meta site name"/>
-->
<meta property="og:url" content="http://www.quanutrition.com/Dotcom/new/"/>
<meta property="og:type" content="website"/>
<meta property="og:title" content="title"/>
<meta property="og:image" content="http://quanutrition.com/Dotcom/new//admin/assets/uploads/clients_image/shikhar-dhawan-759.jpg"/>
<meta property="og:description" content="My description"/>
<script type="text/javascript">
<!--
function Redirect() {
window.location="http://www.quanutrition.com/Dotcom/new/";
}
//-->
</script>
</head>
;
<body onload="Redirect()" >
</body>
</html>
Below is the view page where I am setting the session. $clients is the variable that contains the array.
<?php
session_start();
$_SESSION['clients']=$clients;
print_r ($_SESSION);
exit();
?>
Now in the other page I am doing this.
<?php
session_start();
print_r ($_SESSION);
$var = $_SESSION['clients'];
echo $var;
exit();
?>
It is throwing this error - Undefined index: clients. What am I doing wrong?
This is how a single data in my array in $clients look like
Array ( [clients] => Array ( [0] => stdClass Object ( [client_id] => 1 [name] => Shikhar Dhawan [image] => shikhar-dhawan-759.jpg [video] => [content1] => "Nutrition plays a key role in my recovery and performance. Using Sports Gene testing and advance nutritional blood biochemistry helps me. Eating with a plan gets more scientific and result oriented this way."