Solved

using $_SESSION in mixed codeigniter enivronment

Posted on 2011-09-19
3
703 Views
Last Modified: 2012-05-12
Hello,

I am working on a project that (for some reason) has mixed a codeigniter environment with a standard php environment.  Codeigniter based pages have urls to non-codeigniter pages.

I can't seem to get $_SESSION to work.  Cookies are enabled and the session_start is not called until i enter the non-codeigniter code.

Anyone aware of any issues with $_SESSION getting clobbered or disabled  by codeigniter?

Thanks,
0
Comment
Question by:DanRaposo
3 Comments
 
LVL 29

Accepted Solution

by:
fibo earned 500 total points
ID: 36567484
Seems that yes there is a problem with CI, as shown in places such as

http://codeigniter.com/forums/viewthread/73057/#361671 (I would test the first solution of simply placing a session_start(); in all CI pages)

http://codeigniter.com/user_guide/libraries/sessions.html indicates that CI manges its own way session data, so you might consider to build a small php that you would include at the start of each php non-CI page.
Seems that http://codeigniter.com/wiki/Native_session/ would give you a nice solution
0
 
LVL 6

Expert Comment

by:jjperezaguinaga
ID: 36570214
Greetings DanRaposo,

I strongly suggest that you use the native session class CodeIgniter provides. $_SESSION has issues with CodeIgniter. There's no point of using a Framework if you are not going to take advantage of its libraries. If I were you, I would give a look to the Session User Guide (http://codeigniter.com/user_guide/libraries/sessions.html) and replace $_SESSION in your application.

Best regards,
-JJ
0
 

Author Comment

by:DanRaposo
ID: 36980267
Gang,

Unfortunately, we inherited a system that is a mix of CI and non-CI.  We'll just have go one way or the other to resolve this.
0

Featured Post

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article you'll learn how to use Ajax calls within your CodeIgniter application. To explain this, I'll illustrate how to implement a simple contact form to allow visitors to send you an email through your web site.
There is a huge demand for CodeIgniter among the PHP web developers due to its dynamic features and benefits these days. It is one of most popular and agile open source PHP framework for creating robust web applications in PHP web development field.…
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
The viewer will learn how to count occurrences of each item in an array.

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question