CodeIgniter Session Disappear Bug?

Apr 6, 2011

I am using CI 1.7.3 and here are my settings:

$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 0;
$config['sess_encrypt_cookie'] = FALSE;
$config['sess_use_database'] = TRUE;
$config['sess_table_name'] = 'sessions';
$config['sess_match_ip'] = FALSE;
$config['sess_match_useragent'] = TRUE;
$config['sess_time_to_update'] = 300;

I cannot come up with steps that cause the session to expire, it just seems random and is very frustrating for users.


Session Data Disappear When Using Sess_use_database In Codeigniter?

Jun 3, 2011

Im creating a authentication for my web (currently im using codeigniter as my php framework). How come when i set TRUE in the $config['sess_use_database'] = TRUE; my session data's disappears and doesn't display in part of the page. Im trying to display the username of the person who login to the site. When the $config['sess_use_database'] = FALSE; the username displays in the page. anyone experience this problem? how can i resolve this?

View 1 Replies View Related

Subdomain Session Disappear?

Nov 29, 2010

if(!isset($_GET['n'])) {

This page index.php is used in a subdomain. The subdomain is a folder in the root domain,

View 1 Replies View Related

Session Variables Disappear When Popup Window Closes

Mar 30, 2007

I am in window one (of one) and I popup a second window. Everything is fine.  When the popup window closes the entire session in window one is destroyed!! I have tried everything from named sessions to caches, etc.. This does not happen when i start out with two windows open??

View 4 Replies View Related

Session Variable Values Disappear With Additional POST Requests To Same URL?

Jan 7, 2011

It's been a while since I've needed to whip anything substantial up from scratch, so my scripting is a little (lot) fast and loose (weird/inefficient) here.

I'm trying to mock up a script that's essentially a quiz/survey. There are a handful of topics, each with a few screens of yes/no questions. At the end, it returns a list of recommendations based on the answers gathered.

The script is posting back to itself. Using print_r ($_SESSION), it seems like all of the post values for the first screen of questions are being assigned to the session array as expected. When the second screen of questions is answered, their values are assigned as well, but the values for the first set go away completely. This continues through subsequent screens, with the values from the previous screen present and all others before missing.

// database connect
$dbc = mysqli_connect($CFG->dbhost, $CFG->dbuser, $CFG->dbpass, $CFG->dbname);
// set to section 1, page 1 if no values are in _POST array


View 6 Replies View Related

Codeigniter And Uploadify Session - Send Session Data As A Parameter With Uploading Request

Jul 28, 2010

when we use codeigniter session library. i know that flash doesn't forward browser cookies with its request. and i saw many solutions to send the session data as a parameter with uploading request. but it doesn't seems a real solutions for me.

View 1 Replies View Related

Session Dies In CodeIgniter / Directly On The Server Causing The Session To Die?

Jun 10, 2011

I have an app built in CI and I would like that sessions don't die unless users close their browser. In my config file I have the following:

$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 0;
$config['sess_encrypt_cookie'] = FALSE;
$config['sess_use_database'] = FALSE;
$config['sess_table_name'] = 'ci_sessions';
$config['sess_match_ip'] = FALSE;
$config['sess_match_useragent'] = TRUE;
$config['sess_time_to_update'] = 0;

But session still dies after a period of time, is there any other configuration I need to do? Maybe directly on the server that might be causing the session to die?

View 1 Replies View Related

Declaring Own Session Instead Of Session Maintained By Codeigniter?

Dec 31, 2010

Is there any way to define your own session instead of session maintained by codeigniter ?

View 2 Replies View Related

Codeigniter Session Value As Images?

Mar 30, 2011

In my project,I am using pagination and I used these statements to get the page number detail

echo $this->session->userdata('page');

when I print this session value in that page itself, I got the value correctly.and when I click on the particular link and then print that data, I am getting the value like 'images'Why this is happened.But when i write the statements like :


View 1 Replies View Related

Size Of Session In Codeigniter?

Dec 13, 2010

How do I increase the size of the session framework CodeIgniter? The standard size is 04 kb

View 3 Replies View Related

Codeigniter Object In Session?

Sep 4, 2010

I'm writing this login page and I'd like to add the users object to the session. How do I do that? The user object comes from my user model.. For a new instance I write:

$this->load->model('user_model', 'user');

but this won't work:

$this->session->set_userdata('userobject', $this->user);

View 2 Replies View Related

Which Session Library Should Use With CodeIgniter

Sep 7, 2010

I have recently started using CI and with it CI sessions, but I have noticed that one thing in particular is much more time consuming to do with CI sessions than with the base PHP sessions: Arrays. I have an array of data that persists regardless of login/logout called $_SESSION['stats'], I then store data in that array in the form:

$_SESSION['stats']['last_page'] = $_SERVER['REQUEST_URI'];.

And when a user logs out, it saves the stats array in a variable, clears the session, and then loads it back into the new session. The problem is that in order to edit the last_page key, instead of the one line above, I have to use this code:

$stats = $this->CI->session->userdata('stats');
$stats['last_page'] = $_SERVER["REQUEST_URI"];
$this->CI->session->set_userdata('stats', $stats);

This is one of a number of annoyances I find in CI sessions, which cause me to feel dissatisfied with it as my session handler. So my question is: Which session system should I use with CodeIgniter?... is there some reason for using CI sessions?

View 2 Replies View Related

Session Update In Codeigniter?

May 26, 2011

would like to ask if it is possible to update the session data saved in the database in codeigniter,, for example. i have a session userdata(roleID,name,logged_in), so that when someone will login, ill just call the $data['name'] = $this->session->userdata('name'); and echo it in my header view as <?php echo $name; ?>,, the problem is when a user will update his firstname or lastname, and when i do this

$fname = $this->input->post('fname');
$lname = $this->input->post('lname');

View 1 Replies View Related

Codeigniter: User Session Keeps Expiring

Mar 31, 2011

I'm using CodeIgniter, and I'm having a small issue with sessions. I've set 'sess_expiration' in config.php to 0 so that the user session will never expire, yet users -even myself- are still occasionally kicked out and asked to login again! (i'm storing sessions in the DB btw)

The way I validate a user's session is by basically checking if user_id (which I've previously stored in the session is TRUE or FALSE. If it's FALSE then it asks them to login again.

View 1 Replies View Related

Codeigniter - Finding A Session Library?

Jul 11, 2009

I have been using the CodeIgniter system for a while now - but it has it's short comings. I am grateful for what it taught me, but now I need a library for a new non-codeigniter project and so I am looking around for on which libraries have things right and which don't. I will probably have to take pieces from several libraries to get everything I need.

I just took a look a the Kohana PHP session library and I like how it returns to the native PHP way of using the $_SESSION superglobal instead of forcing a change to $this->session for data access. At any rate, I wanted to know if there were other good session libraries out there I might be messing. There is a lot that must be handled in a session besides just CRUD functionally.

Support for NON-cookie based session passing (i.e. Facebook or Flash uploaders) "Flash data" that only lasts for the next page load and then is auto-removed. Works with $_SESSION or $this->session so that programmers don't have to change existing code. Supports setting a new session id (i.e. session_id('new id')) in case you want to change the id mid-way through the page. Saves all data at the end of the page request instead of each time data is added or removed (saves extra DB queries).


View 3 Replies View Related

CodeIgniter Session Object Cannot Be Found?

Jun 4, 2010

I'm working on a model that tracks user data and stores it in a session, where appropriate. Here's the basic structure of it:

public function __construct() {


View 1 Replies View Related

CodeIgniter Session Cookie Domain?

Apr 25, 2011

It appears with the following cookie settings below, that cookies are set for the entire domain. For example if I was on [URL]... the cookie would be set for if I was on the cookie would be set for [URL]... If the cookie is set for that does that mean cannot access a cookie from [URL]...


View 1 Replies View Related

MySQL Query In CodeIgniter With Session ID?

Feb 6, 2010

Let's say I have a query:

" SELECT * FROM table
WHERE donor_id = " .$this->session->userdata('id') ."
GROUP BY rating"

However, it appears that I get a mysql syntax error here, citing that $this->session->userdata('id') gives me '25' for example, instead of 25. Are there any workarounds here to prevent $this->session->userdata('id') from being quoted?

View 3 Replies View Related

Jquery Uploadify And Codeigniter Session Id

Nov 27, 2010

The problem is the same. No session id is being passed which causes a lot of problems. This is my config.php :-

$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 2700;
$config['sess_encrypt_cookie'] = FALSE;
$config['sess_use_database'] = FALSE;
$config['sess_table_name'] = 'ci_sessions';

As you can see i have already set sess_match_useragent to false but still my session ids are getting changed. Can anybody tell me how do i pass my session ids in scriptData? Because Codeigniter doesn't use querystring approach instead it builds up pretty urls.

View 1 Replies View Related

Multiple Session Instances Codeigniter?

May 20, 2011

So I have an app built using Codeigniter and we are experiencing some trouble when a session is loaded and someone loads another URL that would start a session with the same app. The problem is that the second session is overwriting the initial session (at least partially) and corrupting the data being sent.We are using database sessions and encryption.

View 1 Replies View Related

Codeigniter's Native Session Class?

Jan 6, 2011

so I switched my application over to the Native Session Class is codeigniter due to some problems with IE and sessions. However now, this session class seems to be logging people out very quickly. I have gone over all the code and can't seem to find the problem. Here's the native session class: [URL]...Also all my config vars are the default setting. I am wondering if this is Native Session's fault or my own. I do use a bool var in another script that is used to determined whether the user is logged in. Just thought I'd throw this out there. BTW, Codeigniter 1.7.3, PHP 5

View 2 Replies View Related

CodeIgniter Loop Through Session User_Data?

Mar 1, 2011

I am trying to create a method that return's an array of all CodeIgniter user_data for use in my library.I cant seem to figure it out... is it possible loop through all CI session userdata and create another array?

private function load_session()
$session = array();

View 1 Replies View Related

CodeIgniter Session And Flash Uploaders?

Jul 14, 2011

I'm trying to solve the problem of session data getting lost when using any flash uploader (uploadify or SWFupload) with CodeIgniter. I have tried by passing the session_id and start session using the old session_id, even then I can not get the data stored in session. Therefore I would like to request if you know any solution of this problem or can recommend me some session library to use instead of codeigniter session library,

View 2 Replies View Related

Codeigniter Check For User Session In Every Controller?

Sep 9, 2010

I have this private session in one of my controllers that checks if a user is logged in:

function _is_logged_in() {
$user = $this->session->userdata('user_data');
if (!isset($user)) { return false; } else { return true; }
Problem is that I have more than one Controller.How can I use this function in those other controllers?Redefining the function in every Controller isn't very 'DRY'.

View 2 Replies View Related

Codeigniter: Storing Users Role In Session?

Sep 25, 2010

Is it safe to store the user's role in Codeigniter's session? The role will determine what function the user will have; that is being a admin, a regular subscriber, or a premium user. I am also storing the session in a database for additional security, but I would like to know if I should use a alternate route, such as querying the user's id and checking their role but I believe that just taking it one step further in authentication.

View 2 Replies View Related

Codeigniter Session Data Not Available In Other Pages After Login?

Mar 15, 2010

So, I have set up a login page that verifies the user's credentials, and then sets codeigniter session data 'email' and 'is_logged_in' and a few other items. The first page after the login, the data is accessible. After that page, I can no longer access the session data. In fact, if I try reloading that first page, the session data is gone.I have tried storing it in the database, storing it unencrypted (bad idea I know, but it was for troubleshooting), and storing it encrypted. I have autoloaded the session library in config.php. Here's an example of the code I'm using to set the session data:

$data = array(
'email' => $this->input->post('username'),
'is_logged_in' => true


View 3 Replies View Related

CodeIgniter Session Issue On Opera And Safari?

Aug 27, 2010

I am using codeigniter 1.7.2.In my web app after logging out, on clicking the back button of the browser the page is reloaded in the logged in page.This issue is occuring on Opera and Safari only.I have disabled cache using meta, but that doesn't help.

<meta http-equiv="PRAGMA" content="NO-STORE" />
<meta http-equiv="Expires" content="-1" />
<meta http-equiv="CACHE-CONTROL" content="NO-STORE" />


View 2 Replies View Related

Codeigniter - Storing Database Results In Session?

Mar 1, 2011

i want to store some session info from a database query, upon log in,but for some reason it isnt letting me set the session userdata!?!Can anyone shed any light as to why?Controller:

function validate_login(){
$this->form_validation->set_rules('email_address', "Email address","required|valid_email");


View 3 Replies View Related

Safe Timeout Value For Codeigniter Session Class?

Aug 11, 2009

I am using codeigniter's session class to handle my PHP sessions. One of the session variables automatically created on every visit to the site is session_id:

The user's unique Session ID (this is a statistically random string with very strong entropy, hashed with MD5 for portability, and regenerated (by default) every five minutes)

On my site I need to have functionality to track unregistered user's and I currently have this implemented by comparing the visitor's session_id with a stored id value in a VISITOR table in the database. This works perfectly except for the fact that the session id times out every five minutes. I would like my application to remember visitors for longer than 5 minutes (kind of like what SO does when you post a question or answer without registering).

My question is this: can you see any security issues with simply extending the regeneration time of the session class (to something like 12 hours)?

Update: based on the answers I've seen so far, it seems like its more of a performance concern rather than a safety issue. Its kinda weird how the codeigniter session class works because when creating a new session, it also creates a new cookie which seems to persist as long as the session. I guess I could create another cookie with the session ID that lasts as long as I need it to. But how much of a performance concern would it be if I were to save the sessions for something like 12 hours? Would it slow things down unless I have millions of unique visitors within a 12 hour period (

View 3 Replies View Related

How CodeIgniter Keeps Session Data Even When Browser Closes

Jul 15, 2011

I wonder how does the session work in CodeIgniter. Isn't the session suppose to be automatically destried when the browser is closed? The CodeIgniter does not destroy the session on browser close by default:

$config['sess_expire_on_close'] = FALSE;

Instead we can set the session expire time: $config['sess_expiration'] = 7200;

Now for example if I set the expiration time to 0, it will keep the session as long as I do not destroy by myself: $this->session->sess_destroy(); So how does the CodeIgniter keeps the session information for specific time, even after the browser is closed? Also, is it secure if use this default setting(of not expiring the session with browser close) to keep user login for few days? (eg. store in session 'logged_in' => TRUE )

View 1 Replies View Related

Codeigniter Create Session And Redirect Not Working In IE?

Dec 22, 2010

I'm using codeigniter and have a simple user login setup.User submits their credentials, checks with the DB if they are valid, if they are the model passes the controller a session ID and is redirected to the user page. If the data is not correct the user is redirected to the login page with an error message. Nothing fancy here. The problems is it doesnt work in IE. I'm not sure if its because of the redirect or the session creation. Works fine in all browsers except IE. I tested ie 8 with windows 7 on parallels and worked fine. The weird thing is that it doesnt work with on a pc with windows 7 IE 8. Can someone tell me why the login page just keeps getting refreshed every time the user goes to login? I was told to try and add this code :

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="Expires" content="-1" />
<meta http-equiv="CACHE-CONTROL" content="NO-CACHE" />

Which did nothing. I also changed the session handler from ci_sessions to cisessions which didnt help either (i saw this on another forum).

View 2 Replies View Related

Storing Multiple Inputs With The Same Name In A CodeIgniter Session?

May 19, 2010

I've posted this in the CodeIgniter forum and exhausted the forum search engine as well, so apologies if cross-posting is frowned upon.Essentially, I've got a single input, set up as <input type="text" name="goal">. At a user's request, they may add another goal, which throws a duplicate to the DOM. What I need to do is grab these values in my CodeIgniter controller and store them in a session variable. My controller is currently constructed thusly:

function goalsAdd(){
$meeting_title = $this->input->post('topic');
$meeting_hours = $this->input->post('hours');[code]....

Currently, obviously, my controller gets the value of each input, writing over previous values in its wake, leaving only a string of the final value. I need to store these, however, so I can print them on a subsequent page. What I imagine I'd love to do is extend the input class to be able to call $this->input->posts('goal'). Eventually I will need to store other arrays to session values. But I'm totally open to implementation suggestion.

View 1 Replies View Related

Access Standard Session Data From Inside CodeIgniter

Sep 20, 2010

I've got a Codeigniter project I'm working on, and using the CI Sessions (stored in a DB), but I need to check for a variable in another $_SESSION from another application (in the same cookie domain), but when I try, from the CI controller to use native PHP sessions to get this one bit of info ($_SESSION['blah']), it looks like CI is stripping out that global $_SESSION data. Anyone know a way I can get at it?I'd like to basically do something like this (with a little more error checking of course):

if (isset($_SESSION['user_id'])){
$this->session->set_userdata('usermap', $_SESSION['user_id']);

View 2 Replies View Related

Alert Or Warn User That Session Will Be Expiring Soon In Codeigniter?

May 11, 2010

Basically I'm looking for a solution where a user is notified five minutes before the session expires.

The ideal solution will be count down notification that will have an option to renew the session.

If the countdown timer expires without the user refreshing the page, I need to log them out.

View 4 Replies View Related

Reset The Value Of A Single Session Array Index In Codeigniter?

Oct 15, 2009

Using a user model which returns an array that looks like this:

$user_data['display_name'] = "John Doe";
$user_data['avatar'] = ./images/user144.jpg";

i create my session using $this->session->set_userdata('user_data',$user_data);

now if on another controller i let the user change his avatar, how can i replace the session variable associated to that?

like $this->session->set_userdata('user_data["avatar"]',$new_avatar);

just wont work right?

View 4 Replies View Related

CodeIgniter - Is Custom Session Data Being Stripped By Facebook

Oct 22, 2009

I'm wondering if there's a way to dump all of the values of $this->session->userdata() I'm working within Facebook, and have a login page, and once that's successful I want to pass around the UID of the current user, and I thought this would work well. I currently have the uid set as follows:


And the result is an inscrutable: this is the preferences form 858f500e167e359edc1942a96f3bac35 So it totally skips over the middle echo containing the uid. Am I not setting this correctly? Is there a way to dump all values of the session array to see what's getting through? UPDATE: I have run var_dump($this->session->userdata) on each the raw website and through Facebook.

On the website it exposes all set values in an array containing 5 values (session_id, IP, User_agent, last_activity, and uid). Within the Facebook chrome however, it only shows the 4 values set by CodeIgniter. I've heard cookies can only be 4k and that encryption could be a problem. Could FB be filling up cookies with its own encrypted (read:larger) data? UPDATE 2 When I comment out the redirect, and just have:


It dutifully returns :test_1234_test: within Facebook. So somewhere during the redirect it's losing this part of the array (but not the whole array). Is it possibly just creating a new session on the redirect page? So that's why it only has the four "stock" variables? If this is the case, I'll need to research how it creates the sessions, and if Facebook clears cookies I suppose. UPDATE 3 So I've turned to using a DB to store session information instead of cookies, thinking FB was either stripping them or colliding with them. I currently have the app set up to


What occurs in the DB is this: So it creates one good record, with the user data, then immediately upon the redirect creates a new session without recognizing the prior one. Can someone explain where the CI framework checks to see if it has a prior session existing? The user manual explains it as "magic" basically.

View 2 Replies View Related

Codeigniter With Extended Class Methods - Session Is Invalid

Jun 30, 2011

It's been a while since I don't use CI and I'm with a starter doubt.

class MY_Controller extends CI_Controller {
public function __construct() {
if(!$this->session->userdata('usuario')) {

What happens is that is the user session is invalid, it will load the login view but as in my Home controller contructor method is calling the view home, its loading both views on the same page.

View 1 Replies View Related

CodeIgniter Customer Controller Class Says Session Is Undefined?

Sep 28, 2010

I'm using CodeIgniter (v1.7.2) and I've created a custom controller that incorporates authentication called MY_Controller (based on David Winter's blog post). When I load any controllers that use this base class, I get this error;

*Message: Undefined property: MY_Controller::$session*

Note that I am autoloading 'session' (and 'MY_controller' as a library) like so:

$autoload['libraries'] = array('database', 'session', 'MY_Controller');

Here is MY_Controller:

class MY_Controller extends Controller {
public function __construct() {
if (!$this->session->userdata('loggedin')) { <-- error is here
header('Location: /sessions/login');


When I var_dump $this->session above where the error occurs, I can see that it is NULL. Even putting $this->load->library('session'); in MY_Controller's constructor doesn't work. Why isn't it loading properly?

View 1 Replies View Related

Access Session Data Inside Ouput Class In Codeigniter?

May 22, 2011

I want to access codeigniter session data i.e $this->session->userdata('session_id');

inside ouput class i.e secure_system_folder/core/Output.php.

View 1 Replies View Related

Include CodeIgniter Web Application Within A Genreated Page - Cannot Start The Session Before The Header Has Been Sent??

Nov 4, 2010

The context:I have a web application (e-commerce in few steps) written in php, I am writing a new version with CodeIgniter.I have to include it within php pages generated by a CMS (sitezen).

/* generated html */
<?php include('my_app/index.php); ?>
/* generated html */

I cannot do anything about the CMS part, like working with an other one...

My problem:With I cannot start the session before the header has been sent, I also get warnings when using the session but I can disable them.

My Workaround:I didn't find any help relevant to my problem. The only workaround I could think of for the old php version is to send an ajax request to a php file starting the session.This is working but there might be a better/cleaner solution, and I don't know how to do it with the CodeIgniter version.I'd like to avoid using Iframes too!

View 3 Replies View Related

Php Value Disappear After The First Space ?

Aug 15, 1999

why is the value of a php variable disappear after the first space ? i was coding :-

echo "<a href=javascript:goto('$a[0]',$a[1]')>$a[1]</a>

but if the value of $a[0] is 'T h i s' then when my mouse is over the anchor,the value is :- javascript:goto('T this is a syntax error !

View 3 Replies View Related

Quotes Disappear

Aug 21, 2005

why this: PHP Code:

$prev = "<a href="slideshow.php?c=$country"
onclick="'slideshow.php?c=$country','', 'width="500",
height="500", location="no", menubar="no", status="no",toolbar="no",
scrollbars="no", resizable="no"'); return false">See as slideshow</a>";

echo $prev;

give this output: Code:

<a href="slideshow.php?c=surinam"
onclick="'slideshow.php?c=surinam','', 'width="500, height="500",
location="no", menubar="no", status="no",toolbar="no", scrollbars="no",
resizable="no"'); return false>See as slideshow</a>

(Note the missing quote in width="500 ) If I remove the quotes around the width tag, it does the same thing, but then for height. ANybody know what I am missing?

View 2 Replies View Related

Php Variables Disappear

Jan 27, 2006

I'm having this really huge problem: my php variables just get reseted somewhere along the execution of the script. I've done lots of debugging and could not find the point where the variables go away. In my system (winXP, php5, Apache) all works fine, but at the real server (linux, php4-cgi, apache) it simply does not work. I've tracked the variables all the way up to the output, and they seem to disappear just before.

I'm using a template engine that parses template files by including them in the script,and them using extract() to assign variables to values and returning the buffered output. The server has register_globals on, could this be the problem?

View 2 Replies View Related

Appear And Disappear Options?

Aug 9, 2010

how can i make visible and invisible <option>? here's my code:

<select name='remark'>
echo "<option value='all">All</option>";
echo "<option value='paid">Paid</option>";[code]....

i can do this in vb but i cant do this in php...

View 2 Replies View Related

Prevent Codeigniter Session Library From Sending Set Cookie Header Parameter If Auto Loaded

Jul 9, 2011

I have a codeigniter based website and occasionally I have controllers that are called via AJAX and return JSON values. The problem is since I've already autoloaded the session library anything that's sent as a response from codeigniter has the

Set-Cookie ci_csrf_token=65d0857a89345g5sg5695e71fa687b14c; expires=Sat, 09-Jul-2011 17:00:29 GMT; path=/ header parameter set. This seems like unneccessary bandwidth overhead, is there any way to prevent codeigniter from sending this header?

View 1 Replies View Related