CodeIgniter Forums
URL has a # instead of a ? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: URL has a # instead of a ? (/showthread.php?tid=80443)

Pages: 1 2


URL has a # instead of a ? - richb201 - 11-01-2021

I am trying to get a URL  that has a # sign instead of a ?
PHP Code:
http://staging.researchonline.com:8181/index.php/Configure#access_token=eyJraWQiOiJ4Q3VXZFVIRDBSNlJU 
I am trying to get the access_token. I tried using $_GET['access_token'] but that fails. Is there any way that I can see the entire URL so that I can "cut it up" with parse_url() and get the access_token? 

Parse_url requires the url. Where can I get that from?

I tried using
$config['enable_query_strings'] = TRUE;
$config['access_token'] = '#';

But this results in access_token=NULL.
What am I doing wrong?


RE: URL has a # instead of a ? - John_Betong - 11-01-2021

@richb201,

You’re doing nothing wrong it is just not possible due to the current specifications.

https://stackoverflow.com/questions/3664257/why-is-the-hash-part-of-the-url-not-available-on-the-server-side


RE: URL has a # instead of a ? - richb201 - 11-01-2021

Thx John..


RE: URL has a # instead of a ? - richb201 - 11-02-2021

I have been informed that another way to get the calling URL is to use javascript.

document.getElementById("demo").innerHTML ="Page location is " + window.location.href;

Can someone tell me how I can use javascript that has window.location.href in it to get the URL?


RE: URL has a # instead of a ? - includebeer - 11-02-2021

If the url comes from your own application, then use a ? not a # when you first create this url. They are not the same. 

The "?" is used for query string, where you want to get parameters from the url like you are trying to do. 
The "#" is used to scroll the page to the id following the #. 

The url you posted doesn't make a lot of sense. It should be 
Code:
http://staging.researchonline.com:8181/index.php/Configure?access_token=eyJraWQiOiJ4Q3VXZFVIRDBSNlJU



RE: URL has a # instead of a ? - richb201 - 11-02-2021

Hey Beer. It comes from Okta which is an outh2 application. After discussing with Okta's techs we think that the URL could be seen with javascript's window.location.href. Then I just need to get it back into my CI3 application so I can decode it. I haven't worked in js in a while and don't remember how to do it.


RE: URL has a # instead of a ? - includebeer - 11-02-2021

That's weird they use non standard url like that. You shouldn't have to jump through hoops to make it work.

But yeah, if you really want to read the portion after the #, I think your only solution is to grab the url with JavaScript and send it to your server. Then in your CI application you can use parse_url() to extract all the component, including the fragment (after the #).


RE: URL has a # instead of a ? - John_Betong - 11-02-2021

@richb201,

This may be useful - view page $_SERVER headers:
PHP Code:
echo <pre>print_r($_SERVERTRUE), </pre>



RE: URL has a # instead of a ? - richb201 - 11-02-2021

Thanks. I already checked all the fields through the $_SERVER in the debugger. It is not there. I am just hoping that javascript can see it.


RE: URL has a # instead of a ? - richb201 - 11-03-2021

OK. I managed to hire someone who wrote code to get the access_token into my session variable. I tested it on a jwt decode app. Seems OK. It appears as if the payload data contains a json field that I need. Is there some php function that will decode into the payload into json items?