CodeIgniter Forums
Undefined variable: _SESSION - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Undefined variable: _SESSION (/showthread.php?tid=6510)



Undefined variable: _SESSION - El Forum - 03-01-2008

[eluser]jonnyjon[/eluser]
When I try to use the $_SESSION var I get:

Undefined variable: _SESSION

Does CI do something with the _SESSION var?


Undefined variable: _SESSION - El Forum - 03-01-2008

[eluser]jonnyjon[/eluser]
Figured it out.

Turns out you need make sure to start the session:

session_start();


Undefined variable: _SESSION - El Forum - 03-02-2008

[eluser]Matthew Lanham[/eluser]
check out:

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


Undefined variable: _SESSION - El Forum - 08-04-2011

[eluser]Unknown[/eluser]
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:iConfused");

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.