Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7990387
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T12:59:34+00:00 2026-06-04T12:59:34+00:00

I am working on a web site with login registration functionality.I have implemented the

  • 0

I am working on a web site with login registration functionality.I have implemented the login registration part with reference and forum help,but now I am facing problem with the PHP session.This is my ajax form submit:

   $.ajax({
                    type: "POST",
                    url: "userLogin.php",
                    data: "eid="+eid+"&pwd="+pwd+"&rememberme="+remember,
                    dataType: "html",
                    success: function(msg){
                        if($.trim(msg)!="error")
                        {
                            $("#user_status", window.parent.document).html("Welcome "+msg+"&nbsp;&nbsp;|&nbsp;&nbsp;<a href='forum/logout.php'>Logout</a>");

                            if(window.parent.document.getElementById('post_user_name'))
                                $("#post_user_name", window.parent.document).html("<strong style='color:#333333;'>"+msg+"</strong>");

                            parent.$.fancybox.close();
                        }
                        else{
                            $('#error_common').html("Invalid ID or password.Please try again");
                            $('#error_common').show();
                            return false;
                        }
                    }
                });

This is the PHP code:

             if(isset($_POST['eid']) && isset($_POST['pwd']))
          {     
                $userObj = new Model_Users();
                $username= return_fetched_value($_POST['eid']);
                $password= md5(return_fetched_value($_POST['pwd']));
                $getUserDetails = $userObj->getUserValueByUserNameAndPassword($username,$password);
                /*print_r($getUserDetails);
                exit;*/

                if(count($getUserDetails)>0)
                {   

                    $_SESSION['username'] = $getUserDetails['uname'];
                    $displayUser=$getUserDetails['uname'];  
                    echo $displayUser;

                }
                else
                {
                    //echo "entered here";  
                    echo "error";
                }

          }
          else
          {
            $errorMessage = "You have entered invald username password" ;

          }

Everything works fine,the user logs in and get the username on the login page as here http://www.proptiger.com/,but if I refresh the page the username disappears,but it is still present in the session.I can see it if I do print_r($_SESSION).
The username has been set using the jquery ajax portion.

        $("#user_status", window.parent.document).html("Welcome "+msg+"&nbsp;&nbsp;|&nbsp;&nbsp;<a href='forum/logout.php'>Logout</a>");

Which I think is not persisted,but still there in the session.I am new to jquery ajax and stuck at this.Any constructive comments would be helpful.
Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T12:59:35+00:00Added an answer on June 4, 2026 at 12:59 pm

    This might sound silly but are you sure you’re displaying the username with php on page load or is it just when there’s a login ajax call?

    As far as I can tell your code only displays the username after your AJAX call, but there isn’t anything like <?php echo $_SESSION['username']; ?> when you load the page without ajax.

    I hope my answer is clear enought, but just to conclude: Make sure you echo the username when someone goes directly into your website and not just on the login action.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a working web application which already has a login and registration system.
My web site was working flawless in the old Host , But now i
I am working on a web site with several other developers and we have
I am working on photo sharing web site and i want to add functionality
Consider we have a working computer support incident management web site developed with ASP.NET
I am working on an app which shall log in to a web site
I'm working on a web site (not a web application) in VS 2008 .Net
I'm working on a fairly large web site built in PHP that will potentially
I'm currently working on an intracompany web site which will be viewed on cell
I'm currently working on an ASP.NET web-site. In one of my pages, I had

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.