1

I've succesfully implemented this script: http://blueimp.github.com/jQuery-File-Upload/

(it uses jquery file upload )

The problem is that I am using the following PHP login script in conjection with it: http://phpsense.com/2006/php-login-script/

The image upload script calls an php file to delete/upload images via ajax. I want to secure that php file so that only users who are logged in can access it (since my script is used by admins to update the site).

I included this in the php file called

session_start();

//Check whether the session variable SESS_MEMBER_ID is present or not
if(!isset($_SESSION['SESS_MEMBER_ID']) || (trim($_SESSION['SESS_MEMBER_ID']) == '')) {
    header("location: access-denied.php");
    exit();
}

When I try to access the page through the script it fails saying the session variable was NULL (the user wasn't logged in even though they were).

The really strange thing is its random. If I keep refreshing the page over and over again it eventually succeeds in finding the session variable and loads the images.

The first thing I made sure was that the URL was consistent so I am using the full URL for all my ajax calls so that isn't the issue....

1 Answer 1

2

use this line of code :

var_dump($_SESSION);

and see what it prints.then check queries on your browser.see if it can accept cookies or not

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

5 Comments

I don't think it's that nice to ask for an upvote. Let the community decide if the answer is worth it, people don't upvote in exchange for other upvotes
Okay I was able to monitor the var_dump and it just says "array(0) { }"
so there is a problem with your sessions.go to your tmp directory and see them your self
I hate to ask this, but i'm fairly new to php and sessions in general, and i'm not sure what directory your talking about. I didn't find a "PHPSessions" folder on my server but is always empty...
which server are you using? wamp , xampp , easyphp or what?

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.