PDA

View Full Version : htaccess username


ifisher
06-19-2003, 05:50 PM
I secure my pages using htaccess. How can I reference the username within a java script?

requestcode
06-19-2003, 08:46 PM
Javascript can not do that. It can not read or write to files.

ifisher
06-19-2003, 09:49 PM
In perl you can reference the environement variable
ENV{'REMOTE_USER'}. Can I not reference this variable within javascript?

Choopernickel
06-19-2003, 09:57 PM
only by writing it into a bit of javascript via a server-side language like perl. it's a server variable, and is therefore only available on the server. javascript is for the client, except in some old ASP pages where you could run javascript on the server. by and large, what you'll find here is client-side javascript, not server-side.

so, to sum up: no.

brothercake
06-19-2003, 11:08 PM
Originally posted by Choopernickel
by writing it into a bit of javascript via a server-side language
for example, write the value into a hidden form field, which you can then read with JS

Choopernickel
06-20-2003, 01:41 PM
or even just outputting it directly. Here's what I'd do in ColdFusion:

--page.cfm (pre-processing)--
<cfset myCFvar = 'something'>
<cfoutput>
<script type="text/javascript">
myJSvar = '#myCFvar#';
//(etc.)
</script>
</cfoutput>

--page.cfm (post-processing)--
<script type="text/javascript">
myJSvar = 'something';
//(etc.)
</script>

ifisher
06-24-2003, 05:12 PM
Thanks for all the responses. I decided to write a perl script and embedded in my web page.