0

I upgrade my codeigniter version from 2.1.0 to 2.1.3 from cpanel installatron. Also I integrated tank auth library with codeigniter. I started session_start() in index.php file.

Now I am getting Undefined variable: _SESSION error.

How do I solve this ?

3 Answers 3

2

In Codeigniter 2.X and earlier you cannot use $_SESSION directly before starting session manually.

Instead you can retrieve all session data in a variable and use it like your $_SESSION variable. You can do it as bellow:

$my_session_variable = $this->session->all_userdata();

Here our own variable $my_session_variable will become a copy of $_SESSION.

Sign up to request clarification or add additional context in comments.

Comments

1

Maybe you haven't initiliazed the session library?

Try to:

$this->load->library('session');

That happens to me sometimes.

1 Comment

@Neel tell us what was the issue!
1

check your file that your file is not utf-8 or if you need utf-8 use utf-8 without BOM.
i hope this help you.

2 Comments

Is your OS windows. if you have windows , you can open file with notepad.exe and when save as file prompted save asci or utf-8.
Thanks aya, but not getting solution.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.