Hi,
I have a jquiry/javascript the first line of which is :
document.writeln('<div class="dc-rnav"><a href="javascript:history.go(-1)" title="Go Back">Go Back</a> | <a href="login.pl" title="This will log you out">Log out</a> | <a href="" title="" >$user</a></div>');
You would have spoted
$user which does not fit there, therefore what I would like to do is to add a function to this scrip which which will get the user name from the cookie as long as the session last.
I believe it will be done in two parts, initially when a user logs in, the $user value will be passed to a javascript from within the html through perl script like :
my $user = $q->param('user');
$user = "JAKE";
........
then the javascript function or whatever which will read the $user variable and save it to a cookie under <script> tag within html like :
<script>
document.cookie =
'ppkcookie=logincookie; user=$user path=/'
</script>
Then the function which will read the $user value from cookie which will be in the script I mentioned above which will be called throughout my application so I don't have to pass the $user value around to each and every script within my application.
function readCookie(name) {
get the user name from the cookie
pass it to the following line :
document.writeln('<div class="dc-rnav"><a href="javascript:history.go(-1)" title="Go Back">Go Back</a> | <a href="login.pl" title="This will log you out">Log out</a> | <a href="" title="" >$user</a></div>');
}
I apologize for my English which is not upto the standard. But I hope I have made my point clear.
Many thanks for your help !!
Tonya