Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

in php I need to add the code for a session cookie that persists for three years to the index.php page. I also need to

in php I need to add the code for a session cookie that persists for three years to the index.php page. I also need to Clean up session ID Delete the cookie for the session Get name of the session cookie, Create expiration date in the past and Get session params code is below :

Index.php:

//Add a cookie that is persistent for 3 years.

// Add fields with optional initial message $validate = new Validate(); $fields = $validate->getFields(); $fields->addField('first_name'); $fields->addField('last_name'); $fields->addField('phone', 'Use 888-555-1234 format.'); $fields->addField('email', 'Must be a valid email address.');

$action = filter_input(INPUT_POST, 'action'); if ($action === NULL) { $action = 'reset'; } else { $action = strtolower($action); }

switch ($action) { case 'reset': // Reset values for variables $first_name = ''; $last_name = ''; $phone = ''; $email = '';

// Load view include 'view/register.php'; break; case 'register': // Copy form values to local variables $first_name = trim(filter_input(INPUT_POST, 'first_name')); $last_name = trim(filter_input(INPUT_POST, 'last_name')); $phone = trim(filter_input(INPUT_POST, 'phone')); $email = trim(filter_input(INPUT_POST, 'email'));

// Validate form data $validate->text('first_name', $first_name); $validate->text('last_name', $last_name); $validate->phone('phone', $phone); $validate->email('email', $email);

// Load appropriate view based on hasErrors if ($fields->hasErrors()) { include 'view/register.php'; } else { include 'view/success.php'; } // Clean up session ID // Delete the cookie for the session // Get name of the session cookie // Create expiration date in the past // Get session params break; } ?>

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle 10g Database Administrator Implementation And Administration

Authors: Gavin Powell, Carol McCullough Dieter

2nd Edition

1418836656, 9781418836658

More Books

Students also viewed these Databases questions

Question

15.7 Explain the six steps in the termination interview

Answered: 1 week ago