Results 1 to 9 of 9
  1. #1

    Exclamation Need help on PHP


    Where to put session start/destroy on a reservation system?
    What's their purpose?

    On w3schools, it's quite confusing how they discuss on the matter.

    (Typical client login/logout, make/cancel/view reserve)

    My purpose is that if a client logins, he/she cannot be promted to login again if he/she clicks the back browser button.

  2. #2
    kato kibaw, palihog tabang.

  3. #3
    I'm not an expert in PHP but logically start ang session inig login sa user then destroy inig logout or kng gusto ka naa kay timer if idle sya i.e 30 min then destroy ang session.

  4. #4
    Put the session initialization at the very start of the PHP script before echoing/printing anything.

  5. #5
    you can declare it on the top portion of your script.

    for Example(For session_start):
    <?php
    session_start();
    if (isset($_SESSION['SESS_MEMBER_ID']) && ($_SESSION['SESS_MEMBER_IDNUM'])) {
    $login_user= $_SESSION['SESS_MEMBER_ID'];
    $login_pass= $_SESSION['SESS_MEMBER_IDNUM'];
    $oracledb = $_SESSION['SESS_MEMBER_ORACLEDB'];
    }
    ?>

    For Destroying session:

    <?php
    //Start session
    session_start();
    //Unset the variable SESS_MEMBER_ID stored in session
    unset($_SESSION['SESS_MEMBER_ID']);
    unset($_SESSION['SESS_MEMBER_IDNUM']);
    unset($_SESSION['SESS_MEMBER_ORACLEDB']);
    session_write_close();
    ?>

  6. #6
    try this code:

    *log in interface*

    example, you have two fields (username field,password field) the variable name of username is $user and password is $pass.

    you can code like this:

    session_start();
    $user = $_POST['username'];
    $pass = $_POST['password'];

    $_SESSION['username']=$user;
    $_SESSION['password']=$pass;

    *log-out interface*

    you can declare like this:

    make sure that your session_start() will place at the top.

    session_start();
    if(!(isset($_SESSION['username']))){
    header('Location:index.php');
    exit();
    }else{
    $_SESSION=array();
    session_destroy();
    }

    hope you will understand

  7. #7
    i'll try that one OT.

    i clearly understood the log in part but the log out...hmm...confused why you redirect to index.php on the 'if' and destroyed it on the 'else'.

    this: i am not clear with session_destroy() on how it works x[

  8. #8
    Quote Originally Posted by Badekdek View Post
    i'll try that one OT.

    i clearly understood the log in part but the log out...hmm...confused why you redirect to index.php on the 'if' and destroyed it on the 'else'.

    this: i am not clear with session_destroy() on how it works x[
    ang purpose ani ay iya i declare ang session kung empty ba o dili.. kung empty siya mo direct siya sa index page or log-in page.. example when she/he (user) tried to return or click the back arrow in the internet browser after he/she log-out its automatically direct to the index kay empty naman ang session.. dili sila maka return na..

  9. #9
    nakasabot naq.
    my program works well__________

    tnx guys and my x-groupmate x]

  10.    Advertisement

Similar Threads

 
  1. need help on php!
    By syntax20075 in forum Programming
    Replies: 49
    Last Post: 11-23-2012, 11:18 AM
  2. Need help on PHP
    By Badekdek in forum Programming
    Replies: 1
    Last Post: 01-20-2009, 07:54 AM
  3. Need help on PHP
    By Badekdek in forum Networking & Internet
    Replies: 0
    Last Post: 01-19-2009, 11:25 PM
  4. needs help on HTML
    By tagaisla in forum Websites & Multimedia
    Replies: 11
    Last Post: 11-16-2005, 03:32 AM
  5. I need help on CPU Air flow suggestions
    By HLadik2 in forum Computer Hardware
    Replies: 8
    Last Post: 09-12-2005, 05:20 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
about us
We are the first Cebu Online Media.

iSTORYA.NET is Cebu's Biggest, Southern Philippines' Most Active, and the Philippines' Strongest Online Community!
follow us
#top