I am creating a login process from iphone to django server.
I made Session class using class method, httprequest wrapper using json.
but I don’t know. How can I get session information and matching server session?
if I get session information, (just example pseudo code)
def function(username, password)
if is_authenticate(username, password) == true
login(username, password)
#What send value to iphone
return returnValue(session_id)
How can I send session_id?
This is Login Function
def sign_in(request):
if request.method=='POST':
username = requset.POST['username']
password = request.POST['password']
user = authenticate(username=username, password=password)
list = []
if user is not None:
if user.is_activate:
try:
login(request,user)
list.append( {'fields':
{'login_status':'login success'},})
except:
list.append( {'fields':
{'login_status':'login fail'},})
returnValues = json.dumps(list,cls=DjangoJSONEncoder)
return HttpResponse(returnValues)
Typically the session identifier will get set as a cookie, automatically if you use the default NSURLCONNECTION and NSURLRequest, as for session data, that lives on the server and if you want access to it on your iPhone you will have to develop some sort of API, be it rest based or soap or less formally defined.
So the workflow may be something like
iPhone sends login request: sever responds ok… Set cookie some session data.
iPhone sends userData request: sever responds with Json structure of user data.