Django Login Session ID Extractor Script

In the not too distant past, I worked on an interesting web project in which my participation lasted a brief period. I enjoyed the time I spent working on it. It was a project based on Django and Python, two technologies that I simply love working with. The last tasks I worked on had to do with benchmarking the performance of the Django web application, as well as the webserver it was powered on, which was Apache.

I had to use the excellent and extensive Apache Benchmark utility, also commonly known as simply ab. If you’re not familiar with ab, I recommend you check it out. The problem I faced was not being able to benchmark views that required an authenticated web session. Simply put, I wasn’t able to use ab against views that were login protected. In order to solve this limitation and also to automate the process, I threw together a BASH shell script which I called The Django Login Session ID Extractor. It used a combination of Linux tools to log into the Django application via the login view, and extract out the SESSION ID thus created. This SESSION ID, then, could be passed to the ab command in order for it to hit login protected views.

This script proved really useful during testing, and would’ve even more had I continued to work on it. However, I decided to make the script available on GitHub for the world to use. I am hoping someone might make use of it.

Advertisements