How to tell if the user is logged in

Source: Internet
Author: User
I use PHP to do server-side, C # WinForm do the client. When a user logs in successfully, a B interface is displayed. When a user in the B interface to operate, how the server to determine that a user has logged in, if not logged in will prompt him without permission.


Reply to discussion (solution)

WinForm do not understand, PHP with the session can be.

With an intermediate variable can be, variable assignment is null, when a login success variable is assigned a value, the operation to determine the variable has no value on it!

After PHP login, session,?session deposit into the???
Whether it's WinForm or PHP? The control.

If the memcache, then the session can also be deposited into the memcache. Even if WinForm gets the session value of PHP, it can also be taken directly into the memcache value.

What's the big fan? Pinch

Can use CAS unified authentication
http://www.ibm.com/developerworks/cn/webservices/ws-casestudy/part4/

Does using session not solve?

Give a reference, huh. http://blog.csdn.net/lcawen88/article/details/8534978

I also use C # to do the client, this is very simple oh, the details I do not say, the general method:
First, after the client logs in, using HttpWebRequest to send an HTTP request, assuming that the page is login.php , you'll write a
code that stores the POST data in SESSION (like $_session["username"] = $_post["..."), and C # sends an HTTP request to this page to write the user's login information to the session. Then another management page is manager.php, this page will have a
Judge $_session["username"] code, and with Echo $_session["username"] method to output it, so C # Login manager.php time can get $_session["username"], it and the user name matching, exists and correctly entered the management interface, otherwise pop-up warning

C # with HttpWebRequest, The following code can get the value of the server PHP page on the client

HttpWebRequest myrequest = (HttpWebRequest) webrequest.create ("http://localhost:81/console_revised/" + page);            data = Encoding. GetBytes (postdata);            Myrequest.method = "POST";            Myrequest.contenttype = "application/x-www-form-urlencoded";            Myrequest.contentlength = data. Length;            Stream newstream = Myrequest.getrequeststream ();            Newstream.write (data, 0, data. Length);            Newstream.close ();            HttpWebResponse myresponse = (HttpWebResponse) myrequest.getresponse ();            StreamReader reader = new StreamReader (Myresponse.getresponsestream (), encoding);            String content = Reader. ReadToEnd ();            Reader. Close ();            Myresponse.close ();
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.