?
Solved

Session problems

Posted on 2004-08-12
3
Medium Priority
?
303 Views
Last Modified: 2006-11-17
I am developing an online store who's server is WebStar and uses PhpStar on it. On my own test system. I don't have any problem executing my scripts. But on their system, I can't seem to store session variables.

This page sets the session variables:
http://www.calvarycch.org/ebstore/session.php

This page retrieves them:
http://www.calvarycch.org/ebstore/session2.php

These pages I am using just to figure out why it isn't working, hence their simplicity.
The code I am using to set the variables is the following:

<?php
      session_start();
?>

<!----All the html header stuff etc--->

<?php
      session_register("product1");
      $product1 = "foobar";
      print "The product has been registered";
?>


The code I am using to retrieve is:

<?php
      session_start();
?>

<?php
      print "Your chosen products are:\n\n";
      print $_SESSION['product1'];
?>

Thanks in advance for your help!

-Kyle
0
Comment
Question by:remmuh
  • 2
3 Comments
 
LVL 27

Accepted Solution

by:
Diablo84 earned 500 total points
ID: 11789297
first try replacing this code

<?php
     session_register("product1");
     $product1 = "foobar";
     print "The product has been registered";
?>

with

<?php
     $_SESSION['product1'] = "foobar";
     if (isset($_SESSION['product1'])) {
      print "The product has been registered";
     }
     else {
      print "The product has not been registered";
     }
?>
0
 
LVL 2

Author Comment

by:remmuh
ID: 11789305
BINGO! Thanks. I am still fairly new to PHP; I am actually a ColdFusion developer so I am still adapting to this new language (which I like a lot!).

Thanks for your help!
-Kyle
0
 
LVL 27

Expert Comment

by:Diablo84
ID: 11789314
quite alright :)

just make sure you use

$_SESSION['varname'] = "value";

to set sessions, session_register is no longer required

|)iablo
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses
Course of the Month16 days, 5 hours left to enroll

850 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