How to send and retrieve HTTP cookies from Oracle

কুকি কি সে বিষয়ে আমার এ লেখা না। শুধু এটুক বলি কুকি হলো সার্ভার থেকে ব্রাওজারে পাঠানো ডাটা যা Session management, User
tracking etc. কাজে ব্যাবহিত হয়।

An HTTP cookie (web cookie, browser cookie) is a small piece of data that a server sends to the user’s web browser, that may store it and send it back together with the next request to the same server. Typically, it’s used to know if two requests came from the same browser allowing to keep a user logged-in, for example. It remembers stateful information for the stateless HTTP protocol.  – MDN

আজকে আমরা দেখব ওরাকল ডাটাবেজ থেকে কিভাবে কুকি পাঠান যায়। ওরাকল কুকি ম্যানেজ করার জন্য OWA_COOKIE প্যাকেজ ব্যাবহার করে। OWA_COOKIE প্যাকেজ এর চারটি সাব প্রোগ্রাম আছে –

  1. GET function
  2. GET_ALL procedure
  3. REMOVE procedure
  4. SEND procedure

#1. GET function: GET function ওয়েব ব্রাওজার থেকে একটা নির্দিষ্ট নামের কুকি এবং তার ভ্যালু বের করে আনে।

syntax: 

OWA_COOKIE.GET(
    name           IN       VARCHAR2) -- name of cookie
  RETURN COOKIE;  -- OWA_COOKIE.COOKIE array type data

example: 

DECLARE
   target_cookie OWA_COOKIE.cookie;
BEGIN
   target_cookie := OWA_COOKIE.get (cookie_name);
   -- Print message if the cookie was not found
   IF target_cookie.num_vals = 0
   THEN
      HTP.print ('Cookie not found!');
   ELSE
      FOR i IN 1 .. target_cookie.num_vals
      LOOP
         HTP.print (target_cookie.vals (i));
      END LOOP;
   END IF;
END;

#2 GET_ALL procedure: GET_ALL procedure ওয়েব ব্রাওজারের সকল non expired কুকি এবং তার ভ্যালু বের করে আনে।

syntax: 

OWA_COOKIE.GET_ALL(
   names          OUT      vc_arr,  -- array type 
   vals           OUT      vc_arr,
   num_vals       OUT      INTEGER); -- number of cookie

example: 

DECLARE
   -- Note that vc_arr is in owa_cookie, not owa_text!
   current_cookie_names          OWA_COOKIE.vc_arr;
   current_cookie_vals           OWA_COOKIE.vc_arr;
   n                             INTEGER := 0;
BEGIN
   -- Fetch and print the current cookies
   OWA_COOKIE.get_all (
      current_cookie_names,
      current_cookie_vals,
      n
   );
   FOR i IN 1 .. n
   LOOP
      HTP.print (current_cookie_names (i));
      HTP.print (current_cookie_vals (i));
   END LOOP;
END;

#3 REMOVE procedure: REMOVE procedure বল-পুর্বক কোন একটা কুকির মেয়াদ উত্তীর্ণ করে দেয়। ডিফল্ট ভাবে এর মেয়াদ ০১-০১-১৯৯০ সেট করে।

syntax: 

OWA_COOKIE.REMOVE(
   name           IN       VARCHAR2,
   val            IN       VARCHAR2, 
   path           IN       VARCHAR2   DEFAULT NULL);

#4 SEND procedure: SEND procedure ওয়েব ব্রাওজারের কুকি সেট করে।

syntax:

OWA_COOKIE.SEND(
   name           in       varchar2,
   value          in       varchar2,
   expires        in       date       DEFAULT NULL,
   path           in       varchar2   DEFAULT NULL,
   domain         in       varchar2   DEFAULT NULL,
   secure         in       varchar2   DEFAULT NULL);

example:

BEGIN
owa_util.mime_header('text/html', FALSE);
OWA_COOKIE.SEND(
           NAME => 'CreateCookie',
           VALUE => session_value, -- Could also set this to null
           EXPIRES => SYSDATE + 1, -- use null if set cookie for a session
           PATH => '/',
           DOMAIN => 'mydomain.com', 
           SECURE => NULL);
END;

নোটঃ কুকি ভ্যালুর প্রথমে স্পেসিয়াল ক্যারেক্টার যেমন স্পেস বা কমা দেয়া যাবে না, যদি আপনার টার্গেট ব্রাওজার সাফারি হয়।

Ref: Oracle Doc

Published by

Ali Asgor

Graduate in GES, OCP holder, Self-motivated app developer, Programming lover, Lazy person...

One thought on “How to send and retrieve HTTP cookies from Oracle”

  1. Welcome to Vertex Protocol: Revolutionizing DeFi Trading
    Discover the revolutionary Vertex Protocol, your gateway to the world of decentralized finance (DeFi) trading. As the crypto landscape rapidly evolves, Vertex Protocol stands at the forefront, providing users with unparalleled seamless trading experiences and enhanced liquidity access.
    vertex protocol staking
    What Makes Vertex Protocol Stand Out?
    Vertex Protocol is more than just a trading platform. It is a designed to empower you with:

    Intuitive User Interface: Navigate the complex world of crypto with ease and efficiency.
    Advanced Security: Enjoy peace of mind with industry-leading security protocols and safeguarding of your assets.
    High Liquidity: Access deep liquidity pools to execute large trades with minimal slippage.
    Diverse Asset Options: Explore a wide array of cryptocurrencies and tokens.
    Unlock Potential with Vertex’s Features
    Leverage the full potential of Vertex Protocol with these standout features:

    Decentralized: Trustless and Secure
    Trading on Vertex ensures transparency and autonomy, free from third-party control, making it a trustless and secure choice for crypto enthusiasts.

    Efficient Trading Engine
    Benefit from fast, efficient trade execution supported by state-of-the-art technology that maximizes your trading efficiency.

    Community Governance
    Be a part of a community-driven , allowing you to have a say in the protocol’s future developments.

    Getting Started with Vertex Protocol
    Embarking on your DeFi journey with Vertex is straightforward. To get started:

    Sign up and create your account.
    Securely connect your wallet.
    Begin trading and explore diverse assets and liquidity options.
    Whether you are a seasoned trader or new to the crypto scene, Vertex Protocol offers the tools and resources you need to succeed.

    Join the Vertex Community
    Participate in webinars, discussions, and forums to stay informed and connected. The vibrant awaits, offering support and insights to enhance your trading journey.

    In conclusion, Vertex Protocol is your ideal partner in navigating the dynamic world of decentralized finance. Start today and experience the future of trading.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.