1. Welcome to TechPowerUp Forums, Guest! Please check out our forum guidelines for info related to our community.

PHP Sessions

Discussion in 'Programming & Webmastering' started by silentbogo, Dec 22, 2013.

  1. silentbogo

    silentbogo

    Joined:
    Nov 20, 2013
    Messages:
    154 (0.46/day)
    Thanks Received:
    46
    I'm having trouble with sessions in PHP.
    Already tried manual coding, something like this:

    PHP:
    <?
    define('UNAME','admin');
    define('UPWD','pass');
    if(!empty(
    $_POST))
    {
        if((
    $_POST['uname']==UNAME)&($_POST['upwd']==UPWD))
        {
                
    session_start();
                
    $_SESSION[key]=crypt(UNAME,UPWD);
        }
    }
    if (isset(
    $_SESSION['key'])&($_SESSION['key']==crypt(UNAME,UPWD)))
    {
        echo 
    "You are in";
    }
    else
    {
         echo 
    "<form method=\"post\" action=\"_self\">
                     <input type=\"text\" name=\"uname\" placeholder=\"User name\" required />
                     <input type=\"password\" name=\"upwd\" required />
                     <input type=\"submit\" />
               </form>"
    ;
    }
    ?>
    Let's say, the main page has a navigation menu and each page has the session checker, akin to this one(just without the session starter).
    The session part worked just fine until the moment I start navigating through the site.
    It just kicks me back to the login screen.

    Also tried to use the third-party login library, but it does the same thing.
     
  2. silentbogo

    silentbogo

    Joined:
    Nov 20, 2013
    Messages:
    154 (0.46/day)
    Thanks Received:
    46
    Never mind. Figured it out myself and now I'm completely aware of how stupid I am. :banghead:
     

Currently Active Users Viewing This Thread: 1 (0 members and 1 guest)

Share This Page