Solved

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

Posted on 2015-01-09
2
55 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Why is this panel heading creating extra space 2 50
Objects on Same Line 2 30
HTML &#0153 2 17
Create CSS Animation for Page Transitions 4 26
Introduction The Google Maps API offers various ways to draw dynamic and static maps.  Using a combination of PHP and JavaScript, you can draw active JavaScript maps that allow pan-and-zoom in the client browser window.  You can also draw "static" …
Find out what you should include to make the best professional email signature for your organization.
In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …

770 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