Results 1 to 8 of 8

Thread: session

  1. #1
    Join Date
    Oct 2004
    Posts
    14

    Unanswered: session

    i am trying to make a page to authenticate username and login in php. i know it can be done with session but am not able to figure it out. do i need to write a separate .php file and call it in the other .html file or i need to do something else.can anybody please help me out?

  2. #2
    Join Date
    Jan 2004
    Location
    India
    Posts
    168
    Let me ask you one thing. Are you tring to authenticate a html file or a php file?
    If it's a php file then it can be simply done by sessions but if it is a html file then you may try it with iframes. I am not sure if it will work. Else you have to parse the html file through php. This can be done in apache.
    I would suggest you to try the iframe method.

    Regards
    Rajesh
    Freelance and Technology Consultant
    -------------------
    Dreams are for ever
    -------------------

  3. #3
    Join Date
    Oct 2004
    Posts
    14

    login authentication

    thanks for your suggestion Rajesh r r

    actually my problem goes this way

    i created a login page that is html page and made a connection to access
    database through php using adodb.

    the login page is displayed by the url lets say www.login.com and when
    when i type the correct password it takes me to say
    www.login.com/page1.html and when incorrect password is given it doesnot
    grant the access to the desired page. it works fine till this.
    now the problem is when i directly give url www.login.com/page1.html in the
    address bar i get the access to the page. so the login page is of no use now.
    one can directly access my private without login. so how can solve this problem.

    smeeta

  4. #4
    Join Date
    Jan 2004
    Location
    India
    Posts
    168
    So you want to authenticate a html page. I woul suggest you to use iframe in the html page.
    In page1.html use iframe in the top. I hope you know what an iframe is. Let the iframe contain the php code that check for login.
    if you are using sessions then you could use like this
    $username=$HTTP_SESSION_VARS['username'];
    if($username=='')
    {
    header("Location: invalid_login.html");
    }
    This is just an idea to validate the login in the html file. Now some times (am not sure) this will only change the page in the iframe. In that case you have to use a javascript to change the url of the parent window.

    Regards
    Rajesh
    Freelance and Technology Consultant
    -------------------
    Dreams are for ever
    -------------------

  5. #5
    Join Date
    Oct 2004
    Posts
    14
    hi Rajesh r r

    i donno about iframe and i am also new to php so really having problem with it!!
    i tried your idea using session..but it desnot work....may be i did it the wrong way...can u pls explain it more briefly!!! i would be really be helpful

    smeeta

  6. #6
    Join Date
    Jan 2004
    Location
    India
    Posts
    168
    Hi Smeeta
    You have two option either you can use session cookies or just session variables. I would suggest to use session cookies.
    <?php
    $username=$HTTP_POST_VARS['username'];
    //alfter login validation

    setcookie ("username", $username); // this will set a cookie without any expiry time. means it will exprie when your session expires or your browser closes.

    // this is the code that you have to include in the login validation page.
    ?>
    Now in the after login page you have to include an iframe
    <IFRAME SRC="auth.php" HEIGHT="5"></IFRAME>
    Let say the file is auth.php
    Now in auth.php page you have check for the cookie
    this would be like this.
    <?php
    $username=$HTTP_COOKIE_VARS['username'];
    f($username=='')
    {
    header("Location: invalid_login.html");
    }
    ?>
    If this doesnot change the entire page then you would have to user a javascript to change the location of the parent window.

    Hope that you got some idea.

    Regards
    Rajesh
    Freelance and Technology Consultant
    -------------------
    Dreams are for ever
    -------------------

  7. #7
    Join Date
    Oct 2004
    Posts
    14
    oops!! this doesnot work out.
    dont we need to write the code session_start(); any where?can u help me??

    smeeta

  8. #8
    Join Date
    Jan 2004
    Location
    India
    Posts
    168
    session_start() is required only if you are using sessions to store and retrive the user infromation.
    Let me find another way to do this.
    Rajesh
    Freelance and Technology Consultant
    -------------------
    Dreams are for ever
    -------------------

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •