Skip to content

Commit

Permalink
Merge 7710fd0 into 105ec5c
Browse files Browse the repository at this point in the history
  • Loading branch information
rossp committed Jun 16, 2014
2 parents 105ec5c + 7710fd0 commit 4d98361
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion user_sessions/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,15 @@ class SessionMiddleware(object):
def process_request(self, request):
engine = import_module(settings.SESSION_ENGINE)
session_key = request.COOKIES.get(settings.SESSION_COOKIE_NAME, None)

x_forwarded_for = request.META.get('HTTP_X_FORWARDED_FOR', '')
if x_forwarded_for:
ip = x_forwarded_for.split(',')[0]
else:
ip = request.META.get('REMOTE_ADDR', '')

request.session = engine.SessionStore(
ip=request.META.get('REMOTE_ADDR', ''),
ip=ip,
user_agent=request.META.get('HTTP_USER_AGENT', ''),
session_key=session_key
)
Expand Down

0 comments on commit 4d98361

Please sign in to comment.