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 6332135
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T18:12:15+00:00 2026-05-24T18:12:15+00:00

I have an index.html file which I want to run some jQuery when it

  • 0

I have an index.html file which I want to run some jQuery when it is loaded. Essentially, I want to check to see if a user is already logged in based on some session variables.

So index.html will contain some jQuery which uses $(document).ready(function(){ });

In this function I want to just fire autheticate.php which checks to see if $_SESSION[‘user’] is set, if it is then it will redirect to home page otherwise it will redirect to login page…

how can I post in jQuery without having a html form? I just want to post to a url…

EDIT:

Based on @jondavidjohn’s answer I changed my web app so that it uses index.php to check sessions:

<?php

session_start();

if(isset($_SESSION['username'])){
  //go to home page
  header('Location: ...home.html');
}else{
  //go to login page
  header('Location: ...login.html');
}

?>
  • 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-05-24T18:12:17+00:00Added an answer on May 24, 2026 at 6:12 pm

    It is surely possible doing this with javascript, but it is not secure at all…

    You need to be checking at the server level for $_SESSION['user'] before you even send the content to the browser…

    My answer would be to do the checking / redirecting with PHP before anything gets sent to the browser, it will be less complicated and more secure…

    The reason a javascript solution is insecure is that you are relying on a technology that resides and is controlled by the client to control access to protected areas.

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

Sidebar

Related Questions

I have a site which has only ONE file: index.html . I just want
I have this html form which calls a php file . The index.html ->
I have html page which is located on hard disk (in the browser: file:///C:/index.html).
I have an upload script that write a index.html file, I modified it to
Absolute beginner question: I have a template file index.html that looks like this: ...
i am using php 5.2.8 i have index.html, which loads LOAD.PHP from IFRAME. iframe
I have a view and template called index.html. I have a image which is
in my code for index.html I use jQuery and have a link with id
I am using jQuery for a simple website and have a main page 'index.html'
I got an .aspx file in which I want to have a file uploader

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.