tags:

views:

384

answers:

3

I am having trouble with a session id not being defined.

The session variable is being called on a page that a form posts to via an ajax/jquery query.

The session variable is called on every other page without a problem. The variable is set when a user logs in, and is checked by an auth.php file. The auth.php file finds the session variable just fine, however, the insert.php file spits out an error: "Undefined index: var....".

Is there a reason for a session variable to get lost?

EDIT: I am calling session_start in my auth.php file. I get an error message if I try to start another session.

Is it possible that the session variable is not being found because the file is posted to via an ajax request?

EDIT/ANSWER: I found out what was wrong. I was using a flash uploader, and sessions are lost when making an upload with flash. Oh what a night.

Thanks for all your help!

+1  A: 

Is the page 'insert.php' has session started? It may be the reason.

Try to start it if the PHP setting is not set to auto start.

session_start();

I also find out print out the $_SESSION sometimes handy.

print_r($_SESSION);

From my experience, there is another possibility, which is the other file is called from different host/servername/IP number, which cause the session variables not found. Although this is quite remote possibility.

In your case, try to check it out just in case.

uuɐɯǝʃǝs
When i call print_r($_SESSION);, I only get "Array()" returned.
superUntitled
A: 

If you redirect not include insert.php you have use session_start();, because session not existing in that page, as far as I know php sessions working only in one page without extra configuration.

lfx
+1  A: 

I found out what was wrong. I was using a flash uploader, and sessions are lost when making an upload with flash.

superUntitled
Most flash uploaders allow you to add additional parameters that are sent along with the upload. You can use this to add the session ID to the flash upload POST...
apinstein
can you set your own answer to the preferred answer? :P
Robert Greiner