Jump to content

AJAX Login With Session Variables Inconsistent At Domain Root


GregL83

Recommended Posts

Hey all  ;D.

I have built a login system using AJAX.  The system worked perfect on my local machine.  Once I uploaded the script to my hosting server I noticed a problem.  I can log in and the session variables are carried to each page; however, when I go to my domain root for example http://domain.com instead of http://domain.com/index.php I run into problems.  The session seems to exist in radical states.  The session variables I set are recognized at random about 40% of the time.  I can hit refresh multiple times and watch myself be logged in and be logged out like a slot machine.  No other page is experiencing this problem.  Even stranger, I logged out and went to domain root http://domain.com and hit refresh and achieved the same results.  My session variables were existent sometimes and non existent other times.  I went back to other pages on my site and the session variables did not exist because I had logged out. Obviously this seems to be a problem with my sessions.  At the top of each page <?php session_start(); ?> is placed.  I then use a login class to check if the user is logged in and set $logged_in equal to true or false.

 

My basic page flow is as follows:

 

LOGIN

random page -> login popup div -> send login form elements to ajax page located in ajax folder -> ajax page uses login class to login or display errors

 

LOGOUT

random page -> logout page -> call login class to destroy session and variables

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.