In this article I will show you how to create and retrieve Cookies in the Image may be NSFW.
Clik here to view.Web App Project Type
The Cookie components aren't available in the Web App Project type.
In a Forms (Web) Project they are under
Image may be NSFW.
Clik here to view. Input Output
Image may be NSFW.
Clik here to view. Web Cookies
Image may be NSFW.
Clik here to view. Clear Cookie
Image may be NSFW.
Clik here to view. Get From Cookie
Image may be NSFW.
Clik here to view. Save To Cookie
Class: LogicBase.Components.Default.IO.ClearCookie
Library: LogicBase.Components.Default.dll
Publisher: Symantec Corporation
Some of the Default.IO is available but not these.
The Dialog Model type is not the same as the Image may be NSFW.
Clik here to view. Forms (Web) Project Type in a Web Application Project.
Since we can't use the components we will have to use another method.
Let's go to the trusty Scripting Component.
Add in the Library (LogicBase.Components.Scripting.dll) to your Project
Find the Image may be NSFW.
Clik here to view. Code (Script) Component
Set Cookie
We will create the 'Set' Component first, this will have 3 parameters:
CookieName - Text
CookieValue - Text
ExpiresMinutes - Number (integer)
No return type
In the namespaces add
System.Web
//Cookie Class
//https://msdn.microsoft.com/en-us/library/system.web.httpcookie(v=vs.71).aspx
System.Object
System.Web.HttpCookie
Namespace: System.Web
C# code:
HttpCookie myCookie = new HttpCookie(CookieName); DateTime now = DateTime.Now; // Set the cookie value. myCookie.Value = CookieValue; // Set the cookie expiration date. myCookie.Expires = now.AddMinutes(ExpiresMinutes); // Add the cookie. HttpContext.Current.Response.Cookies.Add(myCookie);
If you read the MS Articles below you won't see HttpContext.Current.
This is needed for it to work in Workflow.
Get Cookie
For the Get Cookie we need an input of
CookieName - Text
- 'Result variable type' of Text
- 'Result variable name' of Cookie
Again add the namespace of System.Web
Then the following C# code:
HttpCookie myCookie = new HttpCookie(CookieName); myCookie = HttpContext.Current.Request.Cookies[CookieName]; return myCookie.Value;
And now you can use this throughout your project.
To view the Cookies in IE.
F12 - Cache | View Cookie Information
Links
Connect Forum
https://www-secure.symantec.com/connect/forums/need-tutorial-save-cookie-component-usage
MS
// Code: Writing a Cookie (Visual C#)
https://msdn.microsoft.com/en-us/library/aa287547%28v=vs.71%29.aspx
// Code: Reading a Cookie (Visual C#)
https://msdn.microsoft.com/en-us/library/aa287533(v=vs.71).aspx
// HttpCookie Properties
https://msdn.microsoft.com/en-us/library/System.Web.HttpCookie_properties(v=vs.110).aspx