How to prevent sessions keys from splitting for certain characters like dot?
Hello,
I have a URL that I want to set as the session key: http://my.url/some-route, but when I set the session key, it splits the session key to an array when it encounters the dot:
session([$url => $data]);
The result of the above when I use dd(session()->all()) is:
The issue is caused by the dot character being used as a delimiter for array keys in PHP. To prevent this from happening, you can use a different character as the delimiter for the session key. One option is to use an underscore instead of a dot. For example:
This will replace any dots in the URL with underscores before setting it as the session key. When you retrieve the session data, you can simply replace the underscores with dots to get the original URL: