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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T07:28:54+00:00 2026-06-07T07:28:54+00:00

I’m writing an authentication system with mobile jquery and php. The html code is

  • 0

I’m writing an authentication system with mobile jquery and php. The html code is as follows:

    <div data-role = "page" id ="dialogo">
        <a href = "#identificacion" id = "formdialog" data-rel="dialog"> </a>
    </div>
    
     <div data-role = "page" id = "identificacion">
        <div id ="main"> 
            <div id ="caplogin">
                <img src = "images/vives_logo.png"/>
                <p> Acceso</p>
                <div style ="clear:both;"></div>
            </div>
            <div style ="clear:both;"></div>
            <div id ="formlogin">
            <form name ="formautentificacion" id ="formautentificacion" method = "post" action = "" data-ajax="false">
                <table>
                    <tr> <td> Login </td> <td> <input type ="text" name ="user" id ="user" size="30"/></td> </tr>
                    <tr> <td> Password </td><td><input type ="password" name ="pass" id="pass" size="30"/></td></tr>
                    <tr> <td colspan = "2" align ="right"> <input type = "submit" id = "sbmt_aut" name = "sbmt_aut" value = "ENTRAR"/></td>
                </table>
            </form>
            </div>
        </div>
    </div>
    
    <div data-role = "page" id = "pageclients">
      
        <div id = "headerpageclient">
            <a href="index.php" class ="logout" data-role="button" data-icon="delete">SALIR</a> 
        </div>
        <div id = "clientes">
            
        </div>
    </div>
    
    <div data-role = "page" id = "pagepuntosventa">
        <div id = "headerpagepuntoventa">
            
        </div>
    </div>

I have two ajax function to start and destroy php sessions, and use changepage it according with ajax response, for login the the functionality is correct and logout, but the safari back button doesn’t working and falls on the last page.

 $(document).delegate("#dialogo", "pageinit", function() {
    $("#formdialog").click();
})


    $(document).delegate("#identificacion", "pageinit", function() {
    
    
    $("#formautentificacion").submit(function(e){
        e.preventDefault();
        //e.stopImmediatePropagation();
        
        $.ajax({
            type: 'POST',
            url: 'ax/login.php',
            data:$(this).serialize(),
            cache: false,
            success: function(data)
            {
                if(data == 1)
                {
                    //$.mobile.changePage("promocion.php", {transition: "flip"});
                    //window.location = "index.php";
                    $.mobile.changePage("#pageclients", {transition: "flip"});
                }
                else
                {
                    if (data == 2)
                        alert("Usuario bloqueado, 3 intentos fallidos");
                    else
                        alert("Error en la identificación");
                }
                
                $("#user").val("");
                $("#pass").val("");
            }
        })
    })
    
    $(".logout").click(function(e){
        //e.preventDefault();
        logout();
    })
})

$(document).delegate("#pageclients", "pageinit", function() {
    seguridad();
})

Function seguridad() for check that session is on:

session_start();

include("../class/aut.php");
$aut = new aut();

$res = 0;

if (!empty($_SESSION["usuario"]) && !empty($_SESSION["token"]) )
{
    $_SESSION["usuario"] = mysql_real_escape_string($_SESSION["usuario"]);
    $_SESSION["token"] = mysql_real_escape_string($_SESSION["token"]);
    
    if ( $aut->checktoken($_SESSION["usuario"],$_SESSION["token"]) )
    {
        $_SESSION["token"] = md5(rand().$_SESSION["usuario"]);
        $aut->updateToken($_SESSION["usuario"], $_SESSION["token"]);
        $res = 1;
    }
    else
    {
        session_destroy();
        session_unset();
        $res = 0;
        //header("Location: index.php");
        //exit;
    }
}
else
{
    session_destroy();
    session_unset();
    $res = 0;
    //header("Location: index.php");
    //exit;
}

echo $res;
?>

And function logout:

function logout()
{
    $.ajax({
        type: 'GET',
        url: 'ax/logout.php',
        cache:false,
        //async: false,
        success: function(data)
        {
            $("#formdialog").click();
        }
    })
}

I try to close the session and then on each page with the security function to verify the session. But once destroyed the session I can go back to a page and not skip dialogue.

Any ideas?

  • 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-07T07:28:56+00:00Added an answer on June 7, 2026 at 7:28 am

    The button to exit the application I’ve made ​​as follows:

    logout.php

    <?php
    session_start();
    session_unset();
    session_destroy();
    ?>
    

    Js

    function logout()
    {
        $.ajax({
            type: 'GET',
            url: 'ax/logout.php',
            cache:false,
            //async: false,
            success: function(data)
            {
                console.log("LOGOUT");
                //$.mobile.changePage("#dialogo");
            }
    
        })
        $.mobile.changePage("http://10.0.74.199/representantes");
    }
    

    And the link to logout

    <a href="index.php" class ="logout ui-btn-right" data-role="button" data-icon="delete" data-theme="a">Salir</a>
    

    And html for the fisrt page:

    <div data-role = "page" id ="dialogo">
                <a href = "#identificacion" id = "formdialog" data-rel="dialog"> </a>
            </div>
    
             <div data-role = "page" id = "identificacion" data-overlay-theme="f">
                <div id ="main"> 
                    <div id ="caplogin">
                        <img src = "http://10.0.74.199/representantes/images/vives_logo.png"/>
                        <p> Acceso Promoción Vives </p>
                        <div style ="clear:both;"></div>
                    </div>
                    <div style ="clear:both;"></div>
                    <div id ="formlogin">
                    <form name ="formautentificacion" id ="formautentificacion" method = "post" action = ""  data-ajax="false">
                        <table>
                            <tr> <td> Login </td> <td> <input type ="text" name ="user" id ="user" size="30"/></td> </tr>
                            <tr> <td> Password </td><td><input type ="password" name ="pass" id="pass" size="30"/></td></tr>
                            <tr> <td colspan = "2" align ="right"> <input type = "submit" id = "sbmt_aut" name = "sbmt_aut" value = "ENTRAR"/></td>
                        </table>
                    </form>
                    </div>
                </div>
            </div>
    

    And when the first pageinit, force click

    $(document).delegate("#dialogo", "pageinit", function() {
        $("#formdialog").click();
    })
    

    With this if you close the application, but this fails when I click back button history, index.php not redirect to initial dialeg.
    Any ideas?

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,

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.