0

I have the following URL after checkout -

https://www.mywebsite.com/register/?session_id=cs_test_a1LrWp5FzCp18vnxTXyQVwpCVwBE7HL0rkbyvea8i9QCVIJoxqIXxMbDx9

I would like to extract the session ID part of this url to use -

cs_test_a1LrWp5FzCp18vnxTXyQVwpCVwBE7HL0rkbyvea8i9QCVIJoxqIXxMbDx9

I know I can use session_id = url.rsplit('=', 1)[-1] to split it from the url but how do I get python to read the current url?

I have tried path_info = request.META.get('PATH_INFO') but that just reads '/register/'

mkrieger1
  • 19,194
  • 5
  • 54
  • 65
KieranDL3
  • 83
  • 10
  • Does this answer your question? [Retrieving parameters from a URL](https://stackoverflow.com/questions/5074803/retrieving-parameters-from-a-url) – mkrieger1 Sep 16 '21 at 23:01
  • In those examples the url is hardcoded in. I can split the url fine, it is the method of getting the current url that I can't work out – KieranDL3 Sep 16 '21 at 23:09

1 Answers1

0

Fixed this with:

url = request.META['QUERY_STRING']
session_id = url.rsplit('=', 1)[-1]
Jeremy Caney
  • 7,102
  • 69
  • 48
  • 77
KieranDL3
  • 83
  • 10