• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

login/logout link

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...
 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic