Gossamer Forum
Home : Products : DBMan SQL : Discussion :

Create an IF statement to recognize whether user is logged in

Quote Reply
Create an IF statement to recognize whether user is logged in
Anyone know how I can create an IF statement in perl that will recognize whether a user is logged in, and if they are will execute A (using session_id)...if they are not will execute B (using uid=default)?

For example:

<a href="db.cgi?do=search_results&db=jdamembers&<%if ??????%>sid=<%session_id%><%else%>uid=default<%endif%>&ls=A&col=Company_Name&sb=Company_Name">A</a>

Where the red highlighted section is the if statement (that I cannot seem to get to work) that will recognize if they are logged in or not. I have tried if session_id, ifnot cookie...but neither seems to work. The default never gets used.

Anyone know?
Quote Reply
Re: [Aberavon] Create an IF statement to recognize whether user is logged in In reply to
You can use:

<%ifnot auth_no_authentication%>
<%if use_cookie%>
<%if Username and Username ne 'default'%>
<a href="db.cgi?do=search_results&db=jdamembers&&ls=A&col=Company_Name&sb=Company_Name">A</a>
<%else%>
<a href="db.cgi?do=search_results&db=jdamembers&uid=default&ls=A&col=Company_Name&sb=Company_Name">A</a>
<%endif%>
<%else%>
<a href="db.cgi?do=search_results&db=jdamembers&sid=<%session_id%>&ls=A&col=Company_Name&sb=Company_Name">A</a>
<%endif%>
<%endif%>

TheStone.

B.
Quote Reply
Re: [TheStone] Create an IF statement to recognize whether user is logged in In reply to
Thank you for the prompt reply, and I can see where you are going with this. But is there a section of code missing in the area I have highlighted in red?

<%ifnot auth_no_authentication%>
<%if use_cookie%>
<%if Username and Username ne 'default'%>
<a href="db.cgi?do=search_results&db=jdamembers&&ls=A&col=Company_Name&sb=Company_Name">A</a>
<%else%>
<a href="db.cgi?do=search_results&db=jdamembers&uid=default&ls=A&col=Company_Name&sb=Company_Name">A</a>
<%endif%>
<%else%>
<a href="db.cgi?do=search_results&db=jdamembers&sid=<%session_id%>&ls=A&col=Company_Name&sb=Company_Name">A</a>
<%endif%>
<%endif%>

Thanks!