EllisLab text mark
Advanced Search
     
Undefined variable: _SESSION
Posted: 02 March 2008 01:24 AM
Joined: 2008-02-27
36 posts

When I try to use the $_SESSION var I get:

Undefined variable: _SESSION

Does CI do something with the _SESSION var?

 
Posted: 02 March 2008 01:28 AM   [ # 1 ]   [ Rating: 0 ]
Joined: 2008-02-27
36 posts

Figured it out.

Turns out you need make sure to start the session:

session_start();

 
Posted: 02 March 2008 06:02 AM   [ # 2 ]   [ Rating: 0 ]
Avatar
Joined: 2007-12-06
179 posts

check out:

http://ellislab.com/codeigniter/user-guide/libraries/sessions.html

 Signature 

web design edinburgh
Follow swanify on Twitter
Codeigniter Linkedin Group

 
Posted: 05 August 2011 02:38 AM   [ # 3 ]   [ Rating: 0 ]
Avatar
Joined: 2011-08-05
1 posts

I’m having the same problem, which is ‘Notice: Undefined variable: user_name in c:\Inetpub\wwwroot\nssu2\main_admin.html on line 62’.

This are a few things that i have done to solve my problem, which it will work for you too.

First, on php.ini, you have to activate the ;error_reporting = E_ALL & ~E_NOTICE. Remove ; from error_reporting.

Second, i used echo “<srcipt type=text/javascript>location.href=‘main_admin.html’</srcipt>”; instead of header(“Location: main_admin.html”);

Example:

  $_SESSION[‘AUTH’] = TRUE;
  $_SESSION[‘USERNAME’] = $_POST[‘USERNAME’];
  $_SESSION[‘CAMPUS’] = $_POST[‘CAMPUS’];
  $_SESSION[‘LOGON’] = date(“M d Y H:i:s”);
         
  echo “<srcipt type=text/javascript>location.href=‘main_admin.html’</srcipt>”;

ps: please replace srcipt to script. Cause it bcome a problem when i try to post this msg here.