Welcome Guest, Not a member yet? Register   Sign In
Integrating script with CI
#1

[eluser]aryan_[/eluser]
I've created an app using CI and want to integrate an small script(has its own classes). What I've done to integrate bot is -

Application
System
Public
MyNewApp

I've put new script(non-CI) inside MyNewApp folder. I'm able to access files, but want to know if there is any way to access CI session data inside MyNewApp.

Please help,

Kind Regards
#2

[eluser]BrianDHall[/eluser]
The only way I can think of would be to load up CI and have it pass a reference to MyNewApp to itself. So in your controller you'd do something to load MyNewApp and pass execution to it like:

Code:
MyNewApp::heres_ci(get_instance());

Your new app would be executed and passed a reference to CI, so you could then take that reference and call it:

Code:
MyNewApp:

functions heres_ci(&$ci)
{
// access session info
$ci->db->...
}
#3

[eluser]aryan_[/eluser]
MyNewApp is not using MVC pattern, it has only two classes and rest of code is procedural.

Can I access session data using native php method?
#4

[eluser]umefarooq[/eluser]
yes you can access session data using native php code if you know all session variables e.g

Code:
$_SESSION['user_id'];
#5

[eluser]aryan_[/eluser]
[quote author="umefarooq" date="1261478384"]yes you can access session data using native php code if you know all session variables e.g

Code:
$_SESSION['user_id'];
[/quote]

I tried to access bot no success, even I created a new native session variable, still it is not being accessed.
#6

[eluser]BrianDHall[/eluser]
Ah, well for one if you are looking for CI session info then you won't find it in _SESSION, because CI by default doesn't use it. Are you trying to get CI session data into your other application?

I'd recommend you just alter it directly. In native CI you should examine $_COOKIE (var_dump), or if you store your CI Sessions in a database you can just pull out the data from there, do a little parsing (I think you have to use unserialize on a portion of it), and then off you go.

Trying to use CI helpers in non-CI applications is usually more trouble than its worth, and for just working with shared session data you'd be best served to just go the direct route.




Theme © iAndrew 2016 - Forum software by © MyBB