Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

login/logout link

 
Mark Moore
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a javascript that returns null if a cookie is not present:

I would like to use this script to put on all my html pages a link to: LOGIN
or a link to LOGOUT, (if script returns NULL then the link to Login should be shown otherwise link to logout is shown on HTML page)

I don't know how to go about this,

Mark
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64843
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you sure you want to be doing this in Javascript? It's much more appropriate to handle this sort of thing on the server...
 
Bruno Boehr
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Such functionality can be easily implemented on the server side, and it will be in many ways a better solution than doing that in-browser, because:

- it will work regardless of whether the browser supports JavaScript;

- you won't have to deal with cross-browser compatibility issues;

- the server has access to a lot more information than is available to the script through cookies; for example, you could provide more links to personalized things like the user profile page, his/her unread messages and what not.

Anyhow, I do not see why anyone would want to employ JavaScript when all this is easily doable via server-side logic. Or am I missing something here?
 
Mark Moore
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am looking to make dynamic text in javascripts:
set content of a <DIV> to login if cookie is null or logout if cookie is not null

not sure how to go about it
[ February 23, 2006: Message edited by: Mark Moore ]
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As Bear has stated, containers have server-side functionality implemented that can manage much of this for you, we do not recommend doing it in JavaScript on the client.

If you want to look at the container managed authentication, have a look at FORM based authentication, available in any good J2EE servlet container. If you would still like to do it using JavaScript you can ask a question in the HTML/JS forum or we can move the thread there for you.

Dave
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Mark Moore:
I am looking to make dynamic text in javascripts:
set content of a <DIV> to login if cookie is null or logout if cookie is not null

not sure how to go about it


If you're adamant about doing this in Javascript, then you may want to request that this be moved to the HTML/Javascript forum where the Javascript gurus hang out.
Let us know.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic