i’m using an open api which works with session ids.
A little background:
A user enters my site and get’s a url and session:
domain.tld/somelongsessionhash (which is usually 50 characters long)
A user can now share this url to do some collab work on a file.
i now want to to shorten the somelongsessionhash which i get from the api-service.
i thought i could do it this way:
- Save the somelongsessionhash in the db
- Generate my own shorter hash
- If the own shorter url gets called, php checks the db and gets the real session.
I’m new to php and would love to solve this. Any hints appreciated! 🙂
Well, I’ll give you a short example of what you can do.
Let’s say you store your hash in temporary variable ($hash).
To generate a short string for your URL you can use something like this:
Use that variable and store the value in DB. The only thing left to do is to check if the current URL( http://www.example.com/f65fcb33/ – for example) matches a record in your DB, and do whatever you want.
This is just a sample method, you can always search internet for something more to expand.