Welcome Guest, Not a member yet? Register   Sign In
Retrieve session variable from DB
#1

[eluser]domenico_d[/eluser]
Hi,

I need to integrate a non CI source page in CI Project.
In this source i need to retrieve a variable stored in table ci_session.
There is some function may i use to retrieve the variable or the only way is read the table and parsing the field "user_data" ?

Thank's
#2

[eluser]Aleazus[/eluser]
I'm unsure why you can't retrieve the variable from your view's controller function and calling it in your view. You can load the variable with php without codeigniter scripting, either way.

Hope this helps.
-Sean
#3

[eluser]InsiteFX[/eluser]
[quote author="domenico_d" date="1289785441"]Hi,

I need to integrate a non CI source page in CI Project.
In this source i need to retrieve a variable stored in table ci_session.
There is some function may i use to retrieve the variable or the only way is read the table and parsing the field "user_data" ?

Thank's[/quote]

And what do you consider a non ci source page?

InsiteFX
#4

[eluser]Aleazus[/eluser]
I'm really unsure what you are asking for. I would assume retrieving variables from your session cookie would be done by:

$this->session->userdata('');
#5

[eluser]domenico_d[/eluser]
Thank' to all for answers!

this is the scenario

In controller i have :



<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Folder extends Controller {

function Folder()
{
parent::Controller();

}

function index()
{
# external page where i don't use CI

header("location: http://localhost/pf3.0/folder.php");

}

}

(user is logged and $this->session->userdata('session_id') is full)



in folder.php (non CI module) i have :


...
$var = session_id();
...


but session_id is empty.

Probably i unknow something, my php programmer experience is very low...

Thank's
#6

[eluser]Aleazus[/eluser]
Quote:<?php if ( ! defined(‘BASEPATH’)) exit(‘No direct script access allowed’);

class Folder extends Controller {

function Folder()
{
parent::Controller();

}

function index()
{
# external page where i don’t use CI
header(“location: http://localhost/pf3.0/folder.php”);

}

}

(user is logged and $this->session->userdata(‘session_id’) is full)


in folder.php (non CI module) i have :


...
$var = session_id();


First, when you load up your controller, typically unless you specify an individual route, this will lead you to www.yourwebsite/folder. Doesn't seem like you need to change the header in that regard. Within your controller you can place your php functions that you want to use that are in your 'non CI module'. If you want to seperate this out. You can create a model such as folder_model.php. class Folder_model extends model{} etc.
so to use functions from your model you can call them as so:

$this->load->model('folder_model');
$var = $this->folder_model->session_id();
#7

[eluser]domenico_d[/eluser]
I apologize in advance if I did not understand your answer

I can't divide the "non CI source" in controler / model/ view, don't work.
The only way i find is pass the $var with session_id by POST, but this ok in development, not in production.

Thank's
#8

[eluser]Aleazus[/eluser]
I'm not all too familar with retreiving session variables other than userdata/flashdata. I would suggest searching through the forums to find similar posts related.




Theme © iAndrew 2016 - Forum software by © MyBB