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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T06:18:20+00:00 2026-06-03T06:18:20+00:00

I am trying to add some security to my webpage. My webpage page.html has

  • 0

I am trying to add some security to my webpage.

My webpage “page.html” has lot of javascript scripts and html code. I can change extension to php. I have no problem with that.

I am using an example code I found on internet to understand how session_start works. If I have html extension, it works fine but I can access to the webpage even if I don’t add user and pass. if I use php extension, webpage throws me to the login promt again. With php extension I can’t access to the webpage when I write it on browser.

This is my code to check access: checkAccess.php

<?php
session_start();
//check the autenticated value
if ($_SESSION["autenticado"] != "si") {
//if doesn't exits, goes to login webpage
header("Location: login.php");
exit();
}
?>

And I added this line on the html and php webpage:

<?php include "checkAccess.php";?>

I know it works because I can access with my page in html. But when I change extension to php, it doesn’t work.

Do I have to configure any value in php.ini or something like that?

I add my other php files to check session:

autenticacion.php:

<?
session_start();
if ($_POST["usuario"]=="user" && $_POST["contrasena"]=="123456"){
$_SESSION["autenticado"]= "SI";
header ("Location: mypage.php");
}else {
header("Location: login.php?errorusuario=si");
}
?>

login.php:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> 
<title>Autenticación PHP</title>
</head>
<body>
<h1>Formulario de autenticaci&oacuten</h1>
<?php if(isset($_GET['errorusuario'])){if ($_GET['errorusuario']=="si"){?>
<font color="red"><b>Datos incorrectos</b></font>
<?php }}else{?>
Introduce tu nombre de usuario y contrase&ntildea
<?}?>
<form action="autenticacion.php" method="POST">
<table border="0">
<tr><td>Nombre de usuario:</td><td><input name="usuario" size="25" value=""/></td></tr>
<tr><td>Contrase&ntildea:</td><td><input name="contrasena" size="25" type="password"/>      </td></tr>
<tr><td/><td><input type="submit" value="Inicio de sesión"/></td></tr>
</table>
</form>
Para ingresar, d&eacutebes ingresar <b>pablo</b> en el 1er campo y <b>123456</b> en el    2do.
</body>
</html>

I am using xampp to test page.

  • 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-03T06:18:21+00:00Added an answer on June 3, 2026 at 6:18 am

    Q: Where is $_SESSION["autenticado"] being set?

    Q: Did you do a session_start() there, as well? You MUST call start_session() in BOTH pages.

    Q: What do you see if you echo the value of `$_SESSION["autenticado"]? Why not do a var_dump() of the entire $_SESSION[] array, and see if there’s anything there?

    Q: Did you enable cookies in your browser?

    Here is a good tutorial on PHP sessions:

    • http://www.w3schools.com/php/php_sessions.asp

    Here is the documentation for the $_SESSION[] superglobal (note the “isset($_SESSION)” function you should probably be using in your code):

    • http://php.net/manual/en/reserved.variables.session.php

    And yes, there are session settings in php.ini. But frankly, I wouldn’t mess with any of them except as a last resort, and unless you knew exactly what you were doing. Here’s the documentation:

    • http://php.net/manual/en/session.configuration.php
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to add some security to my ASP.NET 1.0 MVC app (VB), but
I was trying to add some non-production test code by creating a 3rd partial
I am trying to add some security to my computer at home and would
I have a wordpress theme that i'm trying to add some minor security to
I'm trying to add some Input Validation in Classic ASP by using the function/code
Im trying to add some short file names to a Wise installer to fix
I am trying to add some error detection to a script that is used
I am trying to add some WebAPI support to my asp.net 4 RC site,
I am trying to add some logic in this. But I am not sure
I'm trying to add some functionality to dunst, a small notification system. I've never

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.