Skip to Content

Webdynpro Application Logout button- Step by Step implementation

Implement Logout button on Webdynpro Application – Step by

i have seen lot of contents regarding logout functionality
for Webdynpro applications, but unfortunately most did not work (incomplete
steps). So, i thought it’s important to share what i have done to achieve the
logout functionality for my application. This document is created under the
assumption that you already have a Webdynpro component with an application
which requires the logout functionality.


1) Familiar with Webdynpro ABAP concepts.

2) Familiar with Webdynpro ICF Settings

Solution overview:

The solution can be divided into two parts:

Part 1:  creation
of exit plug and minimum ABAP required to fire the exit plug.

Part 2: Integration of java script code in the ICF
application node to clear cookies.

Part 1: Everything you need to do inside your webdynpro component

Create EXIT plug for the window.

image 1.jpg

   Declare the use of window controller in your view.

In the properties tab of the view, declare the usage of your
window controller.

image 3.jpg

Create the logoff button in the view of your Webdynpro
component with an onAction Event.

image 2.jpg

Method onActionLOGOFF will contain the below code.

image 4.jpg

PART 2: Settings in ICF node of your Application.

Execute tcode: SICF and enter your application name in Service
Name field, then Execute.

image 6.jpg

Enter the below Javascript code in Explicit Response page
header or body or both.

java script code

<html><body> <span id=”onloadscript”><NO_TRANSLATION> <!– function DelSso2Cookie(sName,sPath){ var sso2Domain = location.hostname; if (location.hostname.indexOf(“.”)!=0)sso2Domain =location.hostname.substr(location.hostname.indexOf(“.”)+1);p=””;if(sPath)p=” path=”+sPath+”;”;document.cookie = sName+”=0; expires=Fri, 31 Dec 1999 23:59:59GMT;”+p + “domain=”+sso2Domain+”;”; }; try{document.execCommand( ‘ClearAuthenticationCache’ );} catch (e) {}DelSso2Cookie(“MYSAPSSO2″,”/”);–> </NO_TRANSLATION><span style=”font-weight:bold;vertical-align:middle”><h2>

Logged out successfully ! Please login again to resume

</h2></span></span><NO_TRANSLATION><img src=”/sap/public/bc/ur/nw5/1×1.gif” onload=”var onloadscript = document.getElementById(‘onloadscript’); var scriptText = onloadscript.childNodes[0].nodeValue; eval(scriptText);”> </NO_TRANSLATION><h1>

logged out successfully


This java script code will clear the cookies and will
enforce the user to enter the credentials again.

The logon procedure of the service node should only have
” Logon Through HTTP Fields” in the logon procedure as below.

image 5.jpg

PS modification(Document amended):

Please add "SSO authentication " or "SAP logon ticket" as second step in the Alternate logon procedure.
If the system has https port enabled, then the default standard logon procedure will work for the logoff functionality.

The steps are complete now.. Go ahead and test the logout funcationality.image 7.jpg

Click logout and the EXIT plug will clear the cookies, thus enforcing the user to reenter the credentials.

image 8.jpg

Note: The above example is solely based on the requirement i had for my project, so if incase there are any other way of doing this, please comment.

You must be Logged on to comment or reply to a post.
  • Hi KH/ Rama,

         Thanks for your comment !! 🙂   U guys always inspire me .

    Share more to Learn more !!


    • Hi Harsh,

           Thanks for your comment .. Please post your doubts , i would love to answer if i can.



    • I have tested it yet again using standard alv component, i am prompted with the login screen only once.

      If we have https port availale in the system, It works without the ICF node change i.e standard logon procedure for icf setting(dont know how and why).

      Regarding different browsers, i dont have any other browser installed on my machine(not allowed on company asset). i will check this on my own laptop and let you know.

  • Hello Tashi,

    The solution you have provided to delete cookie using javascript is working in IE.

    Is it working in firefox or chrome ? In my case, it is not working.




    • Hi Harsh,

           Tested it in chrome browser, it worked fine .

      Possible cause in your case: javascript needs to be turned on in browser.



      • Hi Tashi,

        Finally, I found a solution to the issue after striving through all the time. The core pain to the problem was custom CSS that I applied to the web dynpro application using the code, altering the URL. That causes web dynpro application to reload several times.

        As a part of solution, I, then assigned CSS, to application by maintaining a parameter on application level at design time.

        Also, I would like to make one point, if you are giving procedure as ALTERNATIVE LOGON PROCEDURE in sicf service entry and using LOGON THROUGH HTTP FIELDS, there is no need to write javascript for deleting cookies. Kindly check the same by removing javascript under ERROR PAGES->LOGOFF PAGE.

        Let me know if I am getting it wrong.

        Thanks & Regards,


        • Hi Harsh,

               The javascript is indeed needed to clear the SSO, however we need to select in the alternate log on procedure (2 steps).

          1 Fields Authentication

          2 SSO Authentication(added in the document)

          I assume the steps you are taking to test may be slightly different from the way i am testing it.

          I followed the steps as below(all in a single window):

          1) launched application in a browser

          2) copied the URL link and pasted in a second tab, the application will open without login prompt

          3) Click logoff in the application

          4)Now when we paste the URL in the second tab, it will ask for the login prompt, Since cookies have been cleared.

          Note: This test was conducted with a single window and multiple tabs on the browser.

          Thanks for your feedback Harsh(i ended up learning more 🙂 )



          • You're welcome 🙂

            And yes,I too ended up knowing the authentication stuff for standard web dynpro applications.

            My all scenarios are working fine now. 🙂

            Thanks & Regards,


  • Hello Tashi,

    I have successfully implemented that scenario on SAP Netweaver 7.0

    Once again I am seeking help on that same issue. Actually I have one sandbox environment (SAP Netweaver 7.31) in which I am trying to implement similar login logoff scenario, but I am stuck somewhere with SAP_SESSION_<SID>_<CLIENT> cookie. Javascript deletes MYSAPSSO2 but my browser retains SAP_SESSION_<SID>_<CLIENT> cookie which does not allow user to logoff.

    It works fine in internet explorer but not in chrome and firefox.



    • Hi Harsh,

           Sorry for the late reply,

      i have tested this in both 7.0    and 7.3 . it seems to work fine. i am not sure what is effecting

  • Hi Tashi,

    I have got the same requirement to do . I have tried the similar way of how you explained in the above document but still it is not working for me. Can you elaborate how you have done the settings in SICF . I assume there should be something which is missing out where it is not clearing the cache.

    Please explain in with little brief. I have done the setting but still it is not working .



    • Hi Satish,

           Steps i followed:

      1) Create Exit Plug

      2) Create the button to trigger the Exit Plug

      3) Include the javascript code into the ICF node(as shown in the document)

      Please test it in IE and use tabs to open multiple instance of the applicaiton.

      how did i test:

      >open the application in IE.

      >open the applicaiton in another tab of the same window (will not ask for credentials)

      > now in the second tab, click "logoff"

      > now if you open another tab, and try to open the application , it will ask you for credentials.



      • Hi Tashi,

        Thanks for your valuable inputs .

        We are able to get the Log out screen successfully but the problem which we heard from Java Scripting person  is the deletion code for clearing the cookies has been commented in the code which is available in above .As I am totally new to Java scripting code could you tell us if the code for clearing the cookies is  commented ?.

        We are using the internet explorer for testing as you have updated but still it is not prompting for user credentials in new tab.

        Request your help.....


        Satish Raju

        • Hi Satish,

          This is the standard java script provided by sap in notes 0001349513 and 0001271220.

          Are you still facing any difficulty in logging off using this script? Once you log off and you are there with netweaver login screen, are you able to login again? What are the problems you are facing?



        • Hi Satish,

               As Harsh has mentioned, this  is a standard java script provided by SAP. Honestly, Even i understand very little about this javascript code, so i suggest you can also paste the javascript code on to the node and test if it solves the purpose.

          Try to test it in the step i had mentioned earlier.



          • Hi Tashi,

            Please find the screen shot of what we are getting finally.We are able to get the Log out page successfully which you can find the screen shot but we are not able delete the cookies.

            Can you share any document where you could create a sample component and send me .



            logout page.png

            logout page.png
  • Hello,

    What is driving you to say that cookies are not being deleted?

    If you trace the flow from start, it should be as follows:

    1) On executing web dynpro application, login screen appears where you login.

    2) On successful login, you get your application page which will be having log off button.

    3) On clicking log off button you fire exit plug which in turn execute your java script to delete cookies and gives you this page you have shared as screen shot.

    4) Now if you refresh your web dynpro application, login page should appear if all went good.



    • Hi Harsh,

      Thanks for your kind support.

      All the steps are getting executed correctly as you said but I am getting a problem with the step 4 , I am not getting the login page when I refresh. I am directly getting the screen with out Netweaver login page.

      Please help me ?



  • Hello,

    So you're missing some or the other step.

    Check below things:

    - have you fired exit plug without URL on log off click?

    - in transaction rz11, check current value of parameters, login/accept_sso2_ticket and login/create_sso2_ticket. It should be 1 & 2 respectively.

    - in sicf, for web service of application, alternative logon procedure must be there. In list below, remove basic authentication from the list.

    - place the above mentioned java script exactly where it is told to



    • Hi Harsh,

      I have looked in all your points provided above and it is same as you said.

      The way I am executing the functionality is .

      1. Launced the url in internet explorer where it is asking for login credentials in one tab.

      2. I have copied the same url and pasted in second tab .Here it is asking for login credentials again which should not be.

      I have done all the sicf setting in my ides system and I am not able to achieve the above said functionality.

      Please help...



      • Hi Satish,

             If you have not missed to mention, i think you havent clicked on the "logout " button and still its acting like a logout functionality.

        So please check your sicf settings again(alternate logon), make sure you include "SSO authentication" or "logon ticket" along with 1st step(login through http fields)

        • Hi Harsh/Tashi,

          For Mozilla Firefox /Chrome you have said to activate the Java scripting setting.

          Please let me how to activate and please let me know if I need to do any more settings in Chrome/Mozilla.

          Please help as this is urgently needed for client.



        • Hi Tashi,

          Thanks for your valuable inputs . Now the logoff functionality is working fine in Internet Explorer but it is not working in Mozilla Firefox and Chrome.

          Please provide me  some inputs what can be done to fix the issue.

          For Mozilla/Chrome I am getting the message logout successfully but it is not clearing the cookies.

          As this is urgent issue please provide me your inputs.



          • Hi Satish,

                 Sorry,i had tested my solution only with IE as thats the onlly browser my client was allowed to use. Please try different settings on icf node. the javascript we wrote is to clear mysapsso2 cookies created by the logon ticket, probably for firefox and chrome, it is not able to clear.

            @Harsh may have something to say on this .. Please share your input on this query.

            Thanks & Regards,


          • Hi Tashi

            I had a talk with Satish. I worked that out successfully in my system but due to some unknown reasons it is not working their system.



  • Hi Tashi/Harsh,

    Thanks for your valuable comments and it worked for me finally in Internet Explorer.

    But this is not working in Mozilla or Chrome . Could you help me out ASAP ?



  • I recently had a customer that was trying to implement this functionality.

    There were some issues with the Javascript snippet as some people above have mentioned. I made a few changes which should fix it:




          <span id="onloadscript" style="display:none">

              function DelSso2Cookie (sName, sPath) {

              var sso2Domain = location.hostname;

              if (location.hostname.indexOf(".") != 0) {

                sso2Domain = location.hostname.substr(location.hostname.indexOf('.') + 1);


              var p = '';

              if (sPath) {

                p = 'path=' + sPath + ';';


              document.cookie = sName + '=0; expires=Fri, 31 Dec 1999 23:59:59GMT;' + p + 'domain=' + sso2Domain + ';';


              try {


              } catch (e) {}

              DelSso2Cookie('MYSAPSSO2', '/');



      <span style="font-weight:bold; vertical-align:middle">

        <h2>Logged out successfully ! Please login again to resume</h2>



          <img src="/sap/public/bc/ur/nw5/1x1.gif" onload="var onloadscript = document.getElementById('onloadscript'); var scriptText = onloadscript.childNodes[0].nodeValue; eval(scriptText);">




  • Hi ,


    The blog is really useful.

    I followed the above steps and everything is working correctly.

    But, when I press Back Button I can still go back to my webdynpro application.

    Has anyone faced this issue or am I doing any step in correctly.