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

  • SEARCH
  • Home
  • 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 7864681
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T23:51:24+00:00 2026-06-02T23:51:24+00:00

I am working with api in php/ajax and i have in every page included

  • 0

I am working with api in php/ajax and i have in every page included test if a user hasnt been logged out because of inactivity after a certain time. It works but in some moments i have troubles. Here’s the story:

I have one file called index.php. Index.php has a div – let’s name it ‘div’. It also has some buttons – let’s name it “new” and “modify”. When i press a button, body of file new.php and modify.php is loaded via ajax method to ‘div’. So far so good. But when user becomes inactive for certain time it should logout him. And it does. But unfortunatelly – and it’s clear why it is happening – logout page is not printed into index.php, but to the body of “div”. It’s easy to understand – pressing “new” button moves me to new.php. New.php checks if i am logged in – i am not so it redirects me to logout.page so new.php is resulting logout page and it becomes a body of my “div”. Here’s the question: how to redirect whole page (index.php) to logout page if i am logged out and not print it in div.
Remember that pressing “new” button doesnt refresh index.php becuase i use ajax. It only refreshes my div. Is it even possible?

  • 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-02T23:51:26+00:00Added an answer on June 2, 2026 at 11:51 pm

    Don’t do your redirect in new.php, instead make that PHP script return some particular value when the user is logged out, analyze that output in your AJAX call and do the redirect via javascript if necessary.

    In other words:

    • if new.php succeeds do what you normally do
    • if new.php returns some “authentication failure” status, do your redirect

    The best way is to encapsulate AJAX responses in a JSON object so you can have both data and response codes for easier analizing on the javascript side.

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

Sidebar

Related Questions

I've recently been working with a simple Twitter API for PHP and came across
I'm working on a php web api that was handed to me with a
I am Working on Google Data api. I am taking credentials from user and
I'm have the following working example to retrieve a specific Wikipedia page that returns
When I'm developing my REST API in PHP I'm working with application/json output, so
I have a simple wikipedia autocomplete using the wikipedia's API. Currently it is working
I'm working with the Facebook Actionscript API (no PHP or Javascript), and I'm having
I'm working with the YouTube Data API per PHP and requesting a video feed
I just started working with the Flickr API today and I have a question:
So, I'm new to working with API's and PHP, so bear with me. I'm

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.