$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>javascript - Navigate to URL with additional header - Stack Overflow|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

javascript - Navigate to URL with additional header - Stack Overflow

matteradmin11PV0评论

Is there anyway we can navigate (via <a/> click) to a URL with additional header in the request ? here's my code :

i have an <a href="#" id="aUsers"/> tag, and then i handle the onClick() event via JQuery :

$('#aUsers').click(function () {
  var spAuthData = sessionStorage.getItem('sp-auth-data');
  window.location.href = '/users.html?sp-auth-data' = spAuthData;
});

I want to put the spAuthData value in the authorization header, so i can have a clean URL

Is there anyway we can navigate (via <a/> click) to a URL with additional header in the request ? here's my code :

i have an <a href="#" id="aUsers"/> tag, and then i handle the onClick() event via JQuery :

$('#aUsers').click(function () {
  var spAuthData = sessionStorage.getItem('sp-auth-data');
  window.location.href = '/users.html?sp-auth-data' = spAuthData;
});

I want to put the spAuthData value in the authorization header, so i can have a clean URL

Share Improve this question asked Sep 7, 2015 at 4:05 sad301sad301 3961 gold badge3 silver badges8 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 3

As far as I know, there is no way to manipulate HTTP headers with a plain url.

You can use headers parameter of jQuery AJAX request if it is suitable in your situation. For example, you can update the contents of some divs with AJAX HTML response.

$.ajax({
    url: '/users.html',
    headers: { 'Authorization': spAuthData }
}).done(function() 
{
});

Otherwise, it looks like you need to make some server-side changes.

But why don't you use cookies or something like this?
Authorization is used only by unauthorized users during authorization. In my opinion, sending this header on every request from the browser manually sounds bad. The best approach is to send this header once during authorization, create a user session and store it in cookies (as an access-token, forms ticket or whatever else).

Post a comment

comment list (0)

  1. No comments so far