Solved

How can I test a php program that using the session varibles?

Posted on 2015-01-09
2
54 Views
Last Modified: 2015-01-16
I have a PHP program that retrieve session variable info during our order process, I like to be able to see the changes to my email message that is created in the PHP program but I cannot process without processing an order, is there any way to run the PHP program even thought the session variable is empty?
0
Comment
Question by:Scott Johnston
2 Comments
 
LVL 83

Accepted Solution

by:
Dave Baldwin earned 500 total points
ID: 40541364
Put some test code at the top of the program that puts some data in the session variables.  I do that frequently to test parts of PHP programs.  Example #1 on http://php.net/manual/en/function.session-start.php shows what I'm talking about.  Once you set the values, you can run the rest of your program.
<?php
// page1.php

session_start();

echo 'Welcome to page #1';

$_SESSION['favcolor'] = 'green';
$_SESSION['animal']   = 'cat';
$_SESSION['time']     = time();

// Works if session cookie was accepted
echo '<br /><a href="page2.php">page 2</a>';

// Or maybe pass along the session id, if needed
echo '<br /><a href="page2.php?' . SID . '">page 2</a>';
?>

Open in new window

0
 

Author Closing Comment

by:Scott Johnston
ID: 40554092
Great idea....Thank you
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Ajax control editor 4 63
Bootstrap input box width 2 35
addressing a specific html page 9 43
Bootstrap 3 website error 14 46
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
This article discusses how to create an extensible mechanism for linked drop downs.
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now