Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sessions and Javascripts! Pls Help 1

Status
Not open for further replies.

Forri

Programmer
Oct 29, 2003
479
MT
Hi All

I have a menu which is created via a js file. When a user logs into the system the menu is creating dynamically according to the rights given to that particular user.

The problem i'm having is that when a user logs on the js file is created and if he logs off and logs on again using a Different user the menu will remain the same as the previous one! This is obviously unacceptable since most users have different rights!

How can i solve this? any ideas pls!


Thanks
Nick
 
this is a cache problem... the first time the page is loaded, the js file is got from the server, but it will be in the local cache (local PC), so if you logout and login, the browser will get the js file from your PC, not the server... that's your problem.

I don't know how to fix it, so I recommend you ask it in the html forum (
Hope this helps you.
 
You could put the js into the page ?, or would that make it too big ?
 
Tooooo big! hehe!

I will try asking the same question within the HTML forum! thanks
 
Can't you put a small JavaScript function on the page that simply forces a refresh? Granted, you'd have to come up with a way to only do it once, but that shouldn't be too hard (maybe a redirect?).

What about a cookie?


SELECT user
FROM users
WHERE common_sense IS EQUAL TO NULL;

-Shrubble
 
Interesting really, if you want a fresh copy of the .js every time you could include it in the html file, the size wouldn't be an issue as the js file would be transported any way.
 
Here's another idea that might help you:

Name your JavaScript file differently every time the page is loaded - use a timestamp in the name. You will not have the caching trouble with random filenames.
 
When you download images (or any http request) if you put a query string sysmbol ad a random number e.g fred.gif?p1=376336 the browser thinks it's a new request, i wonder if the same works with the .js script tags
 
Forri.

I am developing a similar site that provides different menus based on a user's entry into a MySQL database through PHP.

I use a PHP include statement to include menu "X" if user has answered "Y" previously to a question.

Just a thought . . .


-----------------------
[colorface] Michael Mason [colorface]
-----------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top