Gossamer Forum
Home : Products : DBMan SQL : Discussion :

Currently logged in user

Quote Reply
Currently logged in user
Hi,

I'm displaying the name of the currently logged in user somewhere in the site header. That's why I put the following code into the header template:

<%if Username and Username ne default%>Currently logged in: <%Name%><%endif%>

The "ne default" is not in the DBMan documentation, but was necessary because the default user has no name and shouldn't be displayed while viewing the records (otherwise, you will see: " Unknown Tag: 'Name' "). This is because I have some direct links calling the db as default user.

I have done another thing in the footer template (where you have the menu nagivation bar):

<a href="db.cgi?do=search_results&keyword=*&db=<%db%><%if Username and Username ne default%>&User_ID=<%Username%><%endif>&fm=long<%if sdb%>&sdb=<%sdb%><%endif%><%if q%>&q=<%q%><%endif%>">List own records only</a>

<a href="db.cgi?do=search_results&keyword=*&db=<%db%>&fm=long<%if sdb%>&sdb=<%sdb%><%endif%><%if q%>&q=<%q%><%endif%>">List all records</a>


This helps me to let the logged in user just look at a list of his own records while the default user can look at all records. The logged in users would like to doublecheck their records and this can easily be done once they have their "List own records" function.

I just tought I'd drop a note about this here. Let me know what you think. Smile

Oliver
Quote Reply
Re: [olivers] Currently logged in user In reply to
Blush This makes more sense for the third code block of the above example:

<%if Username and Username ne default%><a href="db.cgi?do=search_results&keyword=*&db=<%db%>&fm=long<%if sdb%>&sdb=<%sdb%><%endif%><%if q%>&q=<%q%><%endif%>">List all records</a> <%endif%>

Cheers, Oliver
Quote Reply
Re: [olivers] Currently logged in user In reply to
I found an interesting post concerning this issue:

http://www.gossamer-threads.com/...i?post=236013#236013

I've changed the code in my header template like this:

<%ifnot auth_no_authentication%>
<%if use_cookie%>
<%if Username and Username ne default%>
Currently logged in: <%Name%>
<%endif%>
<%elsif session_id%>Currently logged in: <%Name%>
<%endif%>
<%endif%>


This code can be used both with the sessions and cookies.

Wink Have fun, Oliver