• Administration
  • Spanish Classes
  • Society.
  • Culture.
  • English
    • Arabic
    • Bulgarian
    • Croatian
    • Czech
    • Danish
    • Dutch
    • English
    • Estonian
    • Finnish
    • French
    • Georgian
    • German
    • Greek
    • Hebrew
    • Hindi
    • Hungarian
    • Indonesian
    • Italian
    • Japanese
    • Korean
    • Latvian
    • Lithuanian
    • Norwegian
    • Persian
    • Polish
    • Portuguese
    • Romanian
    • Russian
    • Serbian
    • Slovak
    • Slovenian
    • Swedish
    • Thai
    • Turkish
    • Ukrainian
  • Twitter
  • Facebook
  • Instagram
  • Example of Sessions in PHP
    • Science.
    • Get To Know Us
    • Psychology. Top Definitions
    • History. Top Definitions

    Example of Sessions in PHP

    Php   /   by admin   /   July 04, 2021

    Example of using Sessions in PHP. In this example, we will see how to create sessions, and to be able to use them in other separate pages, until the session of the user, usually when you close the browser.

    File: access.php
    Code:
    session_start ();
    $ _SESSION [access] = true;
    echo "OK";
    ?>

    File: verify.php
    Code:
    session_start ();
    if ($ _ SESSION [access] == true) {
    echo "OK, you are allowed access";
    }
    else {
    echo "Error, you don't have permission.";
    }
    ?>

    In this simple example that we have divided into two files, we see that in the access.php is the file that will create a session called access, and when opening the page it will create the session, with a true or true value and then it will show OK. And then we open verify and it will show us that we have access allowed, since we open access.php. If we have not opened access.php, the verify.php will give us an error, since we do not have the session created that creates access.php. Really simple to understand and easy to implement for user systems in which you do not want to use COOKIES and prefer to use Sessions for more security.

    instagram story viewer
    Tags cloud
    • Php
    Rating
    0
    Views
    0
    Comments
    Recommend to friends
    • Twitter
    • Facebook
    • Instagram
    SUBSCRIBE
    Subscribe to comments
    YOU MIGHT ALSO LIKE
    • Concept in Definition ABC
      Miscellanea
      04/07/2021
      Concept in Definition ABC
    • Concept in Definition ABC
      Miscellanea
      04/07/2021
      Concept in Definition ABC
    • Concept in Definition ABC
      Miscellanea
      04/07/2021
      Concept in Definition ABC
    Social
    675 Fans
    Like
    507 Followers
    Follow
    9047 Subscribers
    Subscribers
    Categories
    Administration
    Spanish Classes
    Society.
    Culture.
    Science.
    Get To Know Us
    Psychology. Top Definitions
    History. Top Definitions
    Examples
    Kitchen
    Basic Knowledge
    Accounting
    Contracts
    Css
    Culture And Society
    Curriculum Vitae
    Right
    Design
    Art
    Job
    Polls
    Essays
    Writings
    Philosophy
    Finance
    Physics
    Geography
    Story
    Mexico History
    Asp
    Popular posts
    Concept in Definition ABC
    Concept in Definition ABC
    Miscellanea
    04/07/2021
    Concept in Definition ABC
    Concept in Definition ABC
    Miscellanea
    04/07/2021
    Concept in Definition ABC
    Concept in Definition ABC
    Miscellanea
    04/07/2021

    Tags

    • Basic Knowledge
    • Accounting
    • Contracts
    • Css
    • Culture And Society
    • Curriculum Vitae
    • Right
    • Design
    • Art
    • Job
    • Polls
    • Essays
    • Writings
    • Philosophy
    • Finance
    • Physics
    • Geography
    • Story
    • Mexico History
    • Asp
    • Administration
    • Spanish Classes
    • Society.
    • Culture.
    • Science.
    • Get To Know Us
    • Psychology. Top Definitions
    • History. Top Definitions
    • Examples
    • Kitchen
    Privacy

    © Copyright 2025 by Educational resource. All Rights Reserved.