Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Code to keep session id alive in non OSC php pages


Recommended Posts

I am in the process of writing a brand new site. Each product has a non OSC separate sales page (php extension) with lots of pictures, and all sorts of navigation.

 

The only page extensions in the site are php.

 

I want to use OSC as the shopping cart, and I am going to put a "Buy it now" button on the separate sales pages (non OSC pages, but written for search engine rankings, and to give customers more product info ). These separate sales pages themselves will send the customer to OSC.

 

Is there code I can put in my php pages that will maintain the session id switching between my php site and the shopping cart (osCommerce) site.

 

In other words if I have a page http://mysite/howtoplaychess.php for example it is a static product sales page called howtoplaychess.php. I would like to include an order now button on that page. I know the code to do that is

 

<a href="howtoplaychess.php?cPath=50&sort=2a&action=buy_now&products_id=1"><img src="images/addtobasket.gif" border=0 width=20 height=15 alt="Add To Basket"></a>

 

If the customer clicks on "Continue shopping" in OSC and then they click on another page from the menu for instance index.php page or howtoplaypoker.php page or privacy.php page or subscribetomyezine.php page etc. I want to insert code in those pages that will keep the session ID alive.

 

Since php pages will allow me to continue session and track session ids, what code do I need to put in my static php pages to make sure the sessions are carried over from the cart to the static pages?

 

Thanks in advance for the help and clarification.

Link to comment
Share on other sites

The simplest way is to keep your pages inside the catalog directory, then include application_top.php and application_bottom.php with each page. After that, you can use index.php to analyze how links are called to maintain sessions and language integrity using the tep_ functions already included with osCommerce.

 

If you understand php coding, it will make sense. If not, try another approach like using links with a target="_blank".

GEOTEX from Houston, TX

 

(George)

Link to comment
Share on other sites

The simplest way is to keep your pages inside the catalog directory, then include application_top.php and application_bottom.php with each page. After that, you can use index.php to analyze how links are called to maintain sessions and language integrity using the tep_ functions already included with osCommerce.

 

If you understand php coding, it will make sense. If not, try another approach like using links with a target="_blank".

 

hi Geotex,

 

Thank you for your answer :D

I uploaded a page called floaters.php in the /cart directory.

 

I tried what you suggested and put the following code in the body. I will show some from header

<-- Startts Here -->

<head>

<title>floater</title>

<meta name="DESCRIPTION" content="test descriptionr.">

<meta name="MSSmartTagsPreventParsing" content="TRUE">

<link rel="stylesheet" href="styles/main.css" type="text/css">

</head>

<body>

<? include"/admin/includes/application_top.php"; ?>

<div class="content">

<div class="whitebox">

<div align="center">

<? include"includes/header.inc"; ?>

</div>

<div align="center">

<h1>Floating Solar Swimming Pool / Spa Lights</h1>

 

<--end of example code -->

I went to OSC and clicked on the picture to bring me to the product page in OSC. Then to For more information, please visit this products webpage. and I visited the products webpage and got the following error

Parse error: parse error, unexpected T_STRING, expecting ',' or ';' in /home/virtual/site598/fst/var/www/html/cart/catalog/floaters.php on line 6

 

Any ideas what is causing this?

 

Thanks

Link to comment
Share on other sites

hi Geotex,

 

Thank you for your answer :D

I uploaded a page called floaters.php in the /cart directory.

 

I tried what you suggested and put the following code in the body. I will show some from header

<-- Startts Here -->

<head>

<title>floater</title>

<meta name="DESCRIPTION" content="test descriptionr.">

<meta name="MSSmartTagsPreventParsing" content="TRUE">

<link rel="stylesheet" href="styles/main.css" type="text/css">

</head>

<body>

<? include"/admin/includes/application_top.php"; ?>

<div class="content">

<div class="whitebox">

<div align="center">

<? include"includes/header.inc"; ?>

</div>

<div align="center">

<h1>Floating Solar Swimming Pool / Spa Lights</h1>

 

<--end of example code -->

I went to OSC and clicked on the picture to bring me to the product page in OSC.  Then to For more information, please visit this products webpage. and I visited the products webpage and got the following error

Parse error: parse error, unexpected T_STRING, expecting ',' or ';' in /home/virtual/site598/fst/var/www/html/cart/catalog/floaters.php on line 6

 

Any ideas what is causing this?

 

Thanks

 

 

1. the application_top.php must be the first thing called, start your page

 

<?php 
require ('includes/application_top.php'); 
$breadcrumb->add(NAVBAR_TITLE, tep_href_link('floater.php', '', 'SSL'));
?>

 

before your

 

<head>
<title>floater</title>

 

2. the above code will use includes/application_top.php, not the one on admin, as it is different than the catalog/includes/application_top.php

 

You may have to play with NAVBAR_TITLE to get the name of your file.

GEOTEX from Houston, TX

 

(George)

Link to comment
Share on other sites

1. the application_top.php must be the first thing called, start your page

 

<?php 
require ('includes/application_top.php'); 
$breadcrumb->add(NAVBAR_TITLE, tep_href_link('floater.php', '', 'SSL'));
?>

 

before your

 

<head>
<title>floater</title>

 

2. the above code will use includes/application_top.php, not the one on admin, as it is different than the catalog/includes/application_top.php

 

You may have to play with NAVBAR_TITLE to get the name of your file.

 

Thank you George. I'll gave it a try to see what happens. unfortunately I got an error

Parse error: parse error, unexpected T_STRING, expecting ',' or ';' in /home/virtual/site598/fst/var/www/html/floaters.php on line 10

 

My header now looks like this

 

<?php echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"> ?>

<?php

require ('includes/application_top.php');

$breadcrumb->add(NAVBAR_TITLE, tep_href_link('floater.php', '', 'SSL'));

?>

<html>

<head>

<title></title>

<title>Floating Solar Swimming Pool / Spa Lights - Solar Floaters</title>

 

I tried the page floaters.php at http://mytestsite.com/floaters.php and also http://mytestsite.com/cart/catalog/floaters.php and got the same error except it refrenced the page in /cart/catalog

 

I had the <?php echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"> ?> in it before as well.

 

I removed the <?php echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"> ?>

 

reposted the page and got the following errors:

Warning: main(includes/application_top.php): failed to open stream: No such file or directory in /home/virtual/site598/fst/var/www/html/floaters.php on line 3

 

Fatal error: main(): Failed opening required 'includes/application_top.php' (include_path='.:/php/includes:/usr/share/php') in /home/virtual/site598/fst/var/www/html/floaters.php on line 3

 

Any ideas? I really appreciate your effort and advice. :thumbsup:

Link to comment
Share on other sites

Thank you George. I'll gave it a try to see what happens. unfortunately I got an error

Parse error: parse error, unexpected T_STRING, expecting ',' or ';' in /home/virtual/site598/fst/var/www/html/floaters.php on line 10

 

My header now looks like this

 

<?php echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"> ?>

<?php

require ('includes/application_top.php');

$breadcrumb->add(NAVBAR_TITLE, tep_href_link('floater.php', '', 'SSL'));

?>

<html>

<head>

<title></title>

<title>Floating Solar Swimming Pool / Spa Lights - Solar Floaters</title>

 

I tried the page floaters.php at http://mytestsite.com/floaters.php and also http://mytestsite.com/cart/catalog/floaters.php and got the same error except it refrenced the page in /cart/catalog

 

I had the <?php echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"> ?> in it before as well.

 

I removed the <?php echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"> ?>

 

reposted the page and got the following errors:

Warning: main(includes/application_top.php): failed to open stream: No such file or directory in /home/virtual/site598/fst/var/www/html/floaters.php on line 3

 

Fatal error: main(): Failed opening required 'includes/application_top.php' (include_path='.:/php/includes:/usr/share/php') in /home/virtual/site598/fst/var/www/html/floaters.php on line 3

 

Any ideas? I really appreciate your effort and advice. :thumbsup:

 

 

what directory is your catalog in? Is it the root or another directory such as "catalog" or "oscommerce" or "store"? floater.php must be in the same directory as your store.

GEOTEX from Houston, TX

 

(George)

Link to comment
Share on other sites

Do you have ssl installed on your store?

 

Vger

 

has nothing to do with whether or not he has SSL installed. This is an osC system call to check for the existence of an SSL call. If not, it is ignored. The error is caused because the path to application_top is invalid because the floater.php is not in the correct directory.

GEOTEX from Houston, TX

 

(George)

Link to comment
Share on other sites

what directory is your catalog in? Is it the root or another directory such as "catalog" or "oscommerce" or "store"? floater.php must be in the same directory as your store.

 

Hi George,

 

Right now the directory catalog is in a directory called cart. /var/www/html/cart/

 

I tried floaters.php in the /var/www/html/cart/catalog, and also in /var/www/html and got the errors I mentioned. I have other product pages in (/var/www/html). That is the directory where I have the directory of my own includes (the headers to my pages - not the OSC ones, pictures of products, etc.)

the directories there are: cart; graphics; includes (mine).

 

In the directory: /var/www/html/cart/ are catalog; extras; as well as the standard OSC files FAQ; Changelog; Readme; Standard; TODO but no product pages.

 

Is this where I need to move floaters.php? Also, should I move the other stuff for my site there? Or would I be better moving everything from cart up one level and deleting cart.

so the directory structure would look like:

/var/www/html/ floaters.php; surfboards.php; sunglasses.php etc., as well as the directories: includes (my own private) graphics(my own), and OSC's catalog; extras directories

 

Thanks again for your help and insight.

Allen

Link to comment
Share on other sites

Hi George,

 

Right now the directory catalog is in a directory called cart. /var/www/html/cart/

 

I tried floaters.php in the /var/www/html/cart/catalog, and also in /var/www/html and got the errors I mentioned. I have other product pages in (/var/www/html). That is the directory where I have the directory of my own includes (the headers to my pages - not the OSC ones, pictures of products, etc.)

the directories there are: cart; graphics; includes (mine).

 

In the directory: /var/www/html/cart/ are catalog; extras; as well as the standard OSC files FAQ; Changelog; Readme; Standard; TODO but no product pages.

 

Is this where I need to move floaters.php? Also, should I move the other stuff for my site there? Or would I be better moving everything from cart up one level and deleting cart.

so the directory structure would look like:

/var/www/html/ floaters.php; surfboards.php; sunglasses.php etc., as well as the directories: includes (my own private) graphics(my own), and OSC's catalog; extras directories

 

Thanks again for your help and insight.

Allen

 

I think I understand. If so, floater.php you would put floater.php in /var/www/html/cart/catalog to get application_top php to work properly. Also don't forget that you have to update any links to other directories on your site called in floater.php.

 

I do question why you have the cart so deep in the structure. If you are using "front end" pages, you probably want var/www/html/catalog. If you plan on using the catalog/index.php as your main page, then var/www/html would be more appropriate.

 

If you are calling your own graphics from the cart, life is a whole lot simpler and whole lot less code intensive if you utilize your catalog directories as much as possible. I have a couple of sites with extensive front ends that I manage, one in particular that has been up for many years. Always have to watch so I know which images directory or which includes directory I'm in. Won't happen on the redesign :'(

GEOTEX from Houston, TX

 

(George)

Link to comment
Share on other sites

I think I understand. If so, floater.php you would put floater.php in /var/www/html/cart/catalog to get application_top php to work properly. Also don't forget that you have to update any links to other directories on your site called in floater.php.

 

I do question why you have the cart so deep in the structure. If you are using  "front end" pages, you probably want var/www/html/catalog. If you plan on using the catalog/index.php as your main page, then var/www/html would be more appropriate.

 

If you are calling your own graphics from the cart, life is a whole lot simpler and whole lot less code intensive if you utilize your catalog directories as much as possible. I have a couple of sites with extensive front ends that I manage, one in particular that has been up for many years. Always have to watch so I know which images directory or which includes directory I'm in. Won't happen on the redesign :'(

 

Hey George,

 

There is some progress. I created a new page with only one php call

 

<?php echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\" ?>"; ?>

<?php

require ('includes/application_top.php');

$breadcrumb->add(NAVBAR_TITLE, tep_href_link('floater.php', '', 'SSL'));

?>

<html>

<head>

<title>Floating Solar Swimming Pool / Spa Lights - Solar Floaters</title>

<body>

 

the page is called floater1.php

 

I loaded it in /cart/catalog as you suggested.

 

When I clicked on the link form the catalog to get to the URL I got the following error

 

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/virtual/site598/fst/var/www/html/cart/catalog/floater1.php:1) in /home/virtual/site598/fst/var/www/html/cart/catalog/includes/functions/sessions.php on line 67

 

But the good part is that the rest of the page came up. Much better than the last few times. All I got those times was a blank page with the error message.

 

I did not change anything in the OSC code anywhere. Any ideas?

 

<I do question why you have the cart so deep in the structure. If you are using "front end" pages, you probably want var/www/html/catalog.>

I'm just testing right now. The ideal structure I would like is to have my front end pages floater.php; index.php inquire.php, etc. all at root level, and OSC at a lower directory mydomain/catalog

 

Regarding product pics, and other graphics (logo) people using the products, numerous pic's of the products, they enhance the sales pages. I want to use OSC more as a simple cart and backend, rather than the major sales pages.

Link to comment
Share on other sites

Hey George,

 

There is some progress. I created a new page with only one php call

 

<?php echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\" ?>"; ?>

<?php

require ('includes/application_top.php');

$breadcrumb->add(NAVBAR_TITLE, tep_href_link('floater.php', '', 'SSL'));

?>

<html>

<head>

<title>Floating Solar Swimming Pool / Spa Lights - Solar Floaters</title>

<body>

 

the page is called floater1.php

 

I loaded it in /cart/catalog as you suggested.

 

When I clicked on the link form the catalog to get to the URL I got the following error

 

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/virtual/site598/fst/var/www/html/cart/catalog/floater1.php:1) in /home/virtual/site598/fst/var/www/html/cart/catalog/includes/functions/sessions.php on line 67

 

But the good part is that the rest of the page came up. Much better than the last few times. All I got those times was a blank page with the error message.

 

I did not change anything in the OSC code anywhere. Any ideas?

 

 

 

Yes. You can NOT have anything loading before application_top.php. Look at your code. You put in <?php echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\" ?>"; ?> at the top of the page.

 

this line goes just before your <html> tag and does not need php brackets.

GEOTEX from Houston, TX

 

(George)

Link to comment
Share on other sites

 

this line goes just before your <html> tag and does not need php brackets.

 

Thank you George, :thumbsup: :thumbsup: :thumbsup:

 

I changed the page as you suggested and it works. One more question if I may.

If I wanted to move floater.php to the root and still call the includes/application_top.php would the correct path be <?php

require ('catalog/includes/application_top.php');

$breadcrumb->add(NAVBAR_TITLE, tep_href_link('floater.php', '', 'SSL'));

?>

this is assuming that the structure is root/catalog all my front end pages in root and OSC in catalog.

Link to comment
Share on other sites

Thank you George, :thumbsup:  :thumbsup:  :thumbsup:

 

I changed the page as you suggested and it works. One more question if I may.

If I wanted to move floater.php to the root and still call the includes/application_top.php would the correct path be <?php

require ('catalog/includes/application_top.php');

$breadcrumb->add(NAVBAR_TITLE, tep_href_link('floater.php', '', 'SSL'));

?>

this is assuming that the structure is root/catalog all my front end pages in root and OSC in catalog.

 

yes, it will work, but -- No, that won't work. You have to write a separate configure.php file and change all the paths in the copy of application_top that would load from outside the catalog folder. Unless you are anxious to get a PHD in PHP and osCommerce, just keep the files you are creating in the catalog directory. :rolleyes:

GEOTEX from Houston, TX

 

(George)

Link to comment
Share on other sites

Waited too long to edit...

 

Don't forget to add

<?php require('includes/application_bottom.php'); ?>

after the closing </html> tag.

 

One site that does move everything out of the catalog directory is www.designerdogregistry.com. It's live, but totally ready for public consumption.

GEOTEX from Houston, TX

 

(George)

Link to comment
Share on other sites

Waited too long to edit...

 

Don't forget to add

<?php require('includes/application_bottom.php'); ?>

after the closing </html> tag.

 

One site that does move everything out of the catalog directory is www.designerdogregistry.com. It's live, but totally ready for public consumption.

 

Thank you George.

 

<You have to write a separate configure.php file and change all the paths in the copy of application_top that would load from outside the catalog folder. Unless you are anxious to get a PHD in PHP and osCommerce, just keep the files you are creating in the catalog directory.>

 

Gnyah, Gnyah, Gnyah, Gnyah, Gnyah >_< In the words of Roseanna Roseanna Dannah "If it isn't one thing it's something else"

 

Would I be better off then moving everything in the catalog directory up to the root?

 

By the way, I had a quick look at the site. How come it does not take up the entire width of the screen? It looks like you set it for 640pix.

Link to comment
Share on other sites

Thank you George.

 

<You have to write a separate configure.php file and change all the paths in the copy of application_top that would load from outside the catalog folder. Unless you are anxious to get a PHD in PHP and osCommerce, just keep the files you are creating in the catalog directory.>

 

Gnyah, Gnyah, Gnyah, Gnyah, Gnyah  >_<  In the words of Roseanna Roseanna Dannah "If it isn't one thing it's something else"

 

Would I be better off then moving everything in the catalog directory up to the root?

 

By the way, I had a quick look at the site. How come it does not take up the entire width of the screen? It looks like you set it for 640pix.

 

Catalog location depends on what you are trying to accomplish. Matter of personal preference.

 

775 px.

GEOTEX from Houston, TX

 

(George)

Link to comment
Share on other sites

Catalog location depends on what you are trying to accomplish. Matter of personal preference.

 

775 px.

 

The bigger sales pages get indexed by the spiders. A person lands on the page, reads about the product decides to buy it and clicks on a buy now button. Adds the product to their cart. Then continues shopping. Maybe clicks on other products in the categories from OSC, or goes on to another web page and follows the navigation from menu's , then finally goes to their cart and completes the transaction.

 

Rather than everything being based around OSC, I want to make OSC secondary, and everything based around my sales pages so I have more flexibility setting up my product sales pages. OSC functioning more as a cart, affiliate manager, and marketing assistant (we now have a similar product of one we sold a bunch of, find out who bought them and let them know we have something new).

 

That sort of thing.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...