php - what is best idea for login and register in android + phpmysql(bigginer) -


i'm expert in php , mysql programming... write php,mysql script users can login, register, have profiles , more... i'm beginner in android programming... write android app have webview show mobile version of site..

i want know: how can check user logged / or not (sessions created php when user login success)? (really want check example $_session['logged'] in android app show specific activity (if session exsits, show activity1 , , if not exit show activity2)

important note : i'm bigginer in android!

sorry english (english, not native language!)

my problem solved! can use tutorial ...... very easy , understandable ... android login , registration php, mysql , sqlite

i not professional. hope can solve problem. have 2 method member system.

first, create data model user.java

-> user.java

class user{  private string username = "";  private string password = "";  // getter , setter.. } 

while user login, create new user object.

user user = new user(); user.setpassword(...); user.setusername(...); 

when need information server httprequest. need information user object

 url url = new url("http://your.server/index.php?username=" + user.getusername() + "&password=" + user.getpassword());  httpurlrequest conn = url.openconnection();  ....... 

further information. save cookie login process.

arraylist<string> cookieslist = new arraylist<string>(); map<string, list<string>> mheadermap = mconnection.getheaderfields(); string headername = ""; for(int = 0; (headername = mconnection.getheaderfieldkey(i)) != null; i++){     if(headername.equals("set-cookie")){         cookieslist.add(mconnection.getheaderfield(i));     } } 

then if send login request. use cookie again , send server.

mconnection.setrequestproperty("cookie", cookie); 

more information here.

on server side.

<?php session_start(); if($_get.count() > 0) $username = $_get['username']; if($_get.count() > 0) $password = $_get['password']; $arr = array();  if($_session['username'] == $username && $_session['password'] == password){  $arr = array("isvalid" => true, "message" => ""); }else{  $arr = array("isvalid" => false, "message" => ""); } echo json_encode($arr); ?> 

on android

if(isvalid){   startacticity(....) } 

Comments

Popular posts from this blog

.htaccess - First slash is removed after domain when entering a webpage in the browser -

Automatically create pages in phpfox -

c# - Farseer ContactListener is not working -