Forums
Our stores are using various Icebreak applications which are invoked via an .asp program (mainly javascript) which retrieves (or asks for and saves on their computer) a cookie with their store number.
We are developing an Icecap application for use by the stores. What would be the best way to determine which store is using it without requiring them to enter their store number every time they use Icecap? As part of the system initialisation, can I call the .asp program described above and save the store number as a session variable? (I could then retrieve it in the breakout program)
Cookies and IceCap
Hi John;
The short answer is - Yes You can; both setting and getting session variables and cookies:
Now let me explai: IceCap and icebreak shares the same session in IceBreak. So you can utilize all IceBreak features in the breakout program.
An example: If you prompt the user in the HTML page for the shop-number, then you can make a AJAX call back to IceBreak that stores this information in a session variable. But beware cross-domain issues.
An other approach is to let you website ( Share Point Server) store the number in a cookie. Later you can retrieve that cookie in the IceCap break out program. You need however to run the IceBreak and icecap from the same domain as you website. Cookies are only available from within the domain where they are created.
Yet another and even more easy possibility is to ask the client for the Shop-number the first time the user are accessing the Break out program for the first time that day – and then let the breakout program create the cookie. Again – IceCap and icebreak shares the same session, so you can do all kind of IceBreak tricks in the icecap breakout.
With this later approach you are centralizing the use and the creation of the cookie to the break out program. Let me show you how that is done:
1: In your break out program you need access to the icebreak features.
1A: You need to bind to the icebreak service program
1B: And you need to include the header file with the IceBreak prototypes - remember to have ICEBREAK on you library list when you compile your Breakout
2: Now you are ready to fill in the action:
Lets assume that your "normal" 5250 ask for the shop-number in a display called DISP0001D. So if display file record DISP0001D are shown we will fill the shop number with the value from the cookie – if that exists, and the bypass the prompt. Otherwise we will actually show DISP0001D and create a new cookie with the value the user enters.
Let see how that code looks:
* ---------------------------------------------------------------------------------------- */ * Copyright [2012] [System & Method A/S] */ * */ * Licensed under the Apache License, Version 2.0 (the "License"); */ * you may not use this file except in compliance with the License. */ * You may obtain a copy of the License at */ * */ * http://www.apache.org/licenses/LICENSE-2.0 */ * */ * Unless required by applicable law or agreed to in writing, software */ * distributed under the License is distributed on an "AS IS" BASIS, */ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ * See the License for the specific language governing permissions and */ * limitations under the License. */ * ---------------------------------------------------------------------------------------- */ * */ * Project . . . : IceBreak */ * Design . . . : Niels Liisberg */ * Function . . : Getting and setting cookies from a breakout program - and also: */ * How to interact with the IceBreak session */ * */ * By Date Task Description */ * -------- ---------- ------- ------------------------------------------------------------ */ * NLI 07.05.2012 0000000 New program - Subproject IceCap */ * ---------------------------------------------------------------------------------------- */ * * Step1: * You need to bind with the ICEBREAK bindirectory, so you need * IceBreak on the library list. Also you need to include * all the IceBreak prototypes - this is the include * Also it can not have a default activation groupe so vi use the *CALLER h debug(*yes) H DFTACTGRP(*NO) H ACTGRP(*CALLER) H bnddir('ICEBREAK') h bnddir('ICECAPEML') h BndDir('EXTUTILITY') /Include qAspHdr,ICECAP /Include qAspHdr,ICECAPEML /Include qAspHdr,ICEBREAK /Include qAspHdr,ExtUtility * ------------------------------------------------------------- * * Main Line * ---------d pVts s *
d vts ds likeds(vtsDS)
d loc ds likeds(vtLocationDS)
d field ds likeds(vtFieldDS)
d shopno s 5 0 inz
c *entry plist
c parm vts
* ---------------------------------------------------------------------------------------- */
/free
pVts = %addr(vts); // Get the pointer the the virtual IceCap 5250 session
vts.showScreen = *on; // assume we will show screens to come
// Only when the screen id is DISP001D:
// The real logic has to test for valid shopnumbers ( the error line or a valid shop name to arrive)
// othwise this code will loop - but for now and the purpose to show interaction with Cookies - it will do
if vtGetScreen(pVts:1:2:8) = 'DISP001D';
shopNo = num(vtGetValueFor(pVts : 'Shop number'));
if (shopNo > 0);
SetCookie('shopno': %char(shopNo): 10000); // Set the shopnumber and let it live in 10,000 seconds
else;
shopNo = num(GetCookie('shopno'));
if (shopNo > 0); // We have a shop number in a cookie
vtSetFieldNo(pVts:1:%char(shopNo)); // Now enter that in the first input field
vtPressKey(pVts: vtENTER); // And press enter
vts.showScreen = *off; // Now bypass this screen
return;
endif;
endif;
endif;
return;