CoolInterview.com - World's Largest Collection of Interview Questions
 Interview Questions  
 Our Services  

Get 9,000 Interview Questions & Answers in an eBook.


  • 9500+ Pages
  • 9000 Question & Answers
  • All Tech. Categories
  • 14 MB Content

    Get it now !!


    Send your Resume to 6000 Companies


  • INTERVIEW QUESTIONS LANGUAGES PHP DETAILS
    Question :
    How i will check that user is, logged in or not. i want to make it a function and i want to use in each page and after login i want to go in current page(same page. where i was working)



    Category PHP Interview Questions
    Rating (0.0) By 0 users
    Added on 7/19/2006
    Views 954
    Rate it!
    Answers:

    For this we can use the session objec($_SESSION)t. When the user login with his/ her user name and password, usually we check those to ensure for correctness. If that user name and password are valid one then we can store that user name in a session and then we can very that session variable has been set or not in a single files and we can include that file in all pages.



    function checkUser()
    {
    //check if username exists in and session & value not equal to null
    if(isset($_SESSION['username']) && $_SESSION['username']!="")
    return true;
    else
    return false;
    }

    if(!checkUser())
    {
    header("Location:login.php");
    }



     Posted by: Syed Yousuf    

    Contact Syed Yousuf  Contact Syed Yousuf


    If you have the better answer, then send it to us. We will display your answer after the approval.
    Name :*
    Email Id :*
    Answer :*
    Verification Code Code Image - Please contact webmaster if you have problems seeing this image code Not readable? Load New Code
    Process Verification  Enter the above shown code:*
    Inform me about updated answers to this question

       
    Related Questions
    View Answer
    How i can get ip address

    View Answer
    what is differenc between mysql_connect and mysql_pconnect




    View Answer
    What is the difference between echo and print statement?

    View Answer
    How i can make a chat page in php in simple

    View Answer
    what is difference between mysql_fetch_array(),mysql_fetch_row() and mysql_fetch_object()
    please insert with example

    View Answer
    How can I maintain the count of how many persons have hit my site?

    View Answer

    Please Note: We keep on updating better answers to this site. Subscribe to our newsletter to get notified when better answer is posted.

    Notify me when better answer is posted!
    Email:

    View ALL PHP Interview Questions

    User Options
    Sponsored Links


    Copyright ©2003-2009 CoolInterview.com, All Rights Reserved.
    Privacy Policy | Terms and Conditions
    Page URL: http://www.coolinterview.com/interview/6175/default.asp?cachecommand=bypass


    Download Yahoo Messenger | Placement Papers| FREE SMS | ASP .Net Tutorial | Web Hosting | Dedicated Servers | Joke of the Day

    0.98