Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 246
  • Last Modified:

How can server side understand an AJAX request is sent from whom!

As I asked above if I have a site alow user login and can be login multi user on a computer (it's mean that don't use cookie) and when I send request to server site file "respond.php" if I'm a loged in user then respond the text: "You're login!" if not respond "Sorry! you have to login before!"

Thanks for your read and waiting for your guide!
1 Solution
Brian BushSolutions ArchitectCommented:
When a user is succesfully authenticated,
you can set a SESSION variable and use it
to verify login status.

<?php session_start();

$_user = login($user); // where login is a user defined method to authenticate and returns username on success

if ($_user) {
    $_SESSION["login"] = $_user;
} else {
    $_SESSION["login"] = "";

Then on any page that you want to verify login status:
<?php session_start();

if ($_SESSION["login"]) {
    echo "You are logged in!";
} else {
    echo "Sorry! You must login first!";



Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now