Welcome Guest, Not a member yet? Register   Sign In
How to access session maintained by codeigniter through normal php ?
#1

[eluser]Unknown[/eluser]
controller :

Code:
$this->load->library('session');
$user_info[$member['id']] = array('contact1'=>$member['contact1'],'contact2'=>$member['contact2'],'email'=>$member['email']);
$this->session->set_userdata($user_info);

I have a view with this code :

Code:
<img >config->item('base_url')?&gt;/application/views/img.php?id=&lt;?php echo $member['id'] ?&gt;&field=email" />

I want to access session in img.php or any turn around to create images by passing id only:
img.php :
Code:
&lt;?php
session_start();

header("Content-type: image/png");
//ob_start();
//$string = '123';
$user_id     = (isset($_GET['id']))?(int)$_GET['id']:'-';
$field_name  = (isset($_GET['field']))? $_GET['field']:'-';
$field_arr   = $_SESSION[$user_id];
$field_value = $field_arr[$field_name];

$font_size = 15;
$width  = ImageFontWidth($font_size) * strlen($field_value);
$height = ImageFontHeight($font_size) + 3;

$im = @imagecreate($width, $height) or die("Cannot Initialize new GD image stream");
$background_color = imagecolorallocate($im, 255, 255, 2);
$text_color = imagecolorallocate($im, 0, 0, 0);
imagestring($im, $font_size, 0, 0,  $field_value, $text_color);
imagepng($im);
?&gt;
#2

[eluser]Eric Barnes[/eluser]
In CodeIgniter sessions are not really sessions but instead cookies. So you would access it with $_COOKIE['var'];
To see all you can use
Code:
var_dump($_COOKIE);




Theme © iAndrew 2016 - Forum software by © MyBB