Post by Retaliate3476 » Wed Aug 10, 2022 4:17 pm

Hi Guys!

Playing around with a site and noticed out of the box that the cart isn't working. Ironic because I only really deployed it so I could see what the cart was like!! Then decided it would be a fun project to try and deploy a working store. So far quite impressed with how simple yet powerful Opencart CMS is compared to Joomla.

Cart does the animation but when you click gives the error "Your Shopping Cart is Empty!" Nothing I seemly do enables me to progress. Doesn't matter how I add something to the cart. Refresh of the page clears the "1 item(s) - {value}" Cart value back to empty

The site is https://www.geekshirts.co.nz

Troubleshooting :

* Forced HTTPS
* RewriteBase / to RewriteBase /htdocs/
* Set HTTPS Cert
*Cleared Browser Cache
*Cleared the 2x Caches within Opencart Admin

Tried researching into what other options I can apply for .htaccess but that appears to be for older versions of opencart?

Please let me know if you need to see any other config files and I will happily supply.

Thanks in Advance!!!

#############################################################################################

Here is my .htaccess file :

# 1.To use URL Alias you need to be running apache with mod_rewrite enabled.

# 2. In your opencart directory rename htaccess.txt to .htaccess.

# For any support issues please visit: http://www.opencart.com

Options +FollowSymlinks

# Prevent Directory listing
Options -Indexes

# Prevent Direct Access to files
<FilesMatch "(?i)((\.tpl|\.twig|\.ini|\.log|(?<!robots)\.txt))">
Require all denied
## For apache 2.2 and older, replace "Require all denied" with these two lines :
# Order deny,allow
# Deny from all
</FilesMatch>


#Test
RewriteBase /

RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

#



RewriteEngine On

### WWW & HTTPS
# ensure www.
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# ensure https
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
##



# SEO URL Settings
RewriteEngine On
# If your opencart installation does not run on the main web folder make sure you folder it does run in ie. / becomes /shop/

RewriteBase /htdocs/
RewriteRule ^sitemap.xml$ index.php?route=extension/feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=extension/feed/google_base [L]
RewriteRule ^system/storage/(.*) index.php?route=error/not_found [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]

### Additional Settings that may need to be enabled for some servers
### Uncomment the commands by removing the # sign in front of it.
### If you get an "Internal Server Error 500" after enabling any of the following settings, restore the # as this means your host doesn't allow that.

# 1. If your cart only allows you to add one item at a time, it is possible register_globals is on. This may work to disable it:
php_flag register_globals off

# 2. If your cart has magic quotes enabled, This may work to disable it:
# php_flag magic_quotes_gpc Off

# 3. Set max upload file size. Most hosts will limit this and not allow it to be overridden but you can try
# php_value upload_max_filesize 999M

# 4. set max post size. uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields
# php_value post_max_size 999M

# 5. set max time script can take. uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields
# php_value max_execution_time 200

# 6. set max time for input to be recieved. Uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields
# php_value max_input_time 200

# 7. disable open_basedir limitations
php_admin_value open_basedir none

Newbie

Posts

Joined
Sun Aug 07, 2022 2:24 pm

Post by ADD Creative » Wed Aug 10, 2022 10:18 pm

What version of OpenCart? What version of PHP? What theme or extensions. What do you have session.cookie_lifetime set to in your PHP settings?

www.add-creative.co.uk


Expert Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by Retaliate3476 » Thu Aug 11, 2022 4:23 am

ADD Creative wrote:
Wed Aug 10, 2022 10:18 pm
What version of OpenCart? What version of PHP? What theme or extensions. What do you have session.cookie_lifetime set to in your PHP settings?
What version of OpenCart? - Version 3.0.3.8
What version of PHP? - PHP Version 7.4.8
What theme or extensions? - Default and no Extensions added
What do you have session.cookie_lifetime set to in your PHP settings?

php.ini :

magic_quotes_gpc = Off
register_globals = Off
default_charset = UTF-8
memory_limit = 64M
max_execution_time = 36000
upload_max_filesize = 999M
safe_mode = Off
mysql.connect_timeout = 20
session.auto_start = Off
session.use_only_cookies = On
session.use_cookies = On
session.use_trans_sid = Off
session.cookie_httponly = On
session.gc_maxlifetime = 3600
allow_url_fopen = On
;display_errors = 1
;error_reporting = E_ALL

Thanks!
Last edited by Retaliate3476 on Thu Aug 11, 2022 7:42 am, edited 1 time in total.

Newbie

Posts

Joined
Sun Aug 07, 2022 2:24 pm

Post by IP_CAM » Thu Aug 11, 2022 4:53 am

RewriteBase /htdocs/
should most likely only be:
RewriteBase /

My Github OC Site: https://github.com/IP-CAM
5'200 + FREE OC Extensions, on the World's largest private Github OC Repository Archive Site.


User avatar
Legendary Member

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland

Post by Retaliate3476 » Thu Aug 11, 2022 5:08 am

IP_CAM wrote:
Thu Aug 11, 2022 4:53 am
RewriteBase /htdocs/
should most likely only be:
RewriteBase /
Hi IP_Cam!!

Here is my Root Folder Structure :

Folders:

.cpanel
.pki
htdocs
mail
ocartdata

Files:
.htaccess
.lastlogin


Here is what is in my htdocs:

Folders:

Admin
catalog
image
system

Files:
.htaccess
config-dist.php
config.php
index.php
php.ini
robots.txt

Let me know if I should change back to "RewriteBase /" and I will give it another go. "RewriteBase /" was what it was set to out of the box.

Cheers!

Newbie

Posts

Joined
Sun Aug 07, 2022 2:24 pm

Post by ADD Creative » Thu Aug 11, 2022 6:40 am

What do you have session.cookie_lifetime set to in your PHP settings? Use phpinfo() to find out.

www.add-creative.co.uk


Expert Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by Retaliate3476 » Thu Aug 11, 2022 7:34 am

ADD Creative wrote:
Thu Aug 11, 2022 6:40 am
What do you have session.cookie_lifetime set to in your PHP settings? Use phpinfo() to find out.
Hi ADD Creative,

session.cookie_lifetime 86400

All Session settings :

Directive Local Value Master Value
session.auto_start Off Off
session.cache_expire 60 60
session.cache_limiter nocache nocache
session.cookie_domain no value no value
session.cookie_httponly 0 0
session.cookie_lifetime 86400 86400
session.cookie_path / /
session.cookie_samesite no value no value
session.cookie_secure 0 0
session.gc_divisor 500 500
session.gc_maxlifetime 1440 1440
session.gc_probability 1 1
session.lazy_write On On
session.name PHPSESSID PHPSESSID
session.referer_check no value no value
session.save_handler files files
session.save_path /php_sessions /php_sessions
session.serialize_handler php php
session.sid_bits_per_character 4 4
session.sid_length 32 32
session.upload_progress.cleanup On On
session.upload_progress.enabled On On
session.upload_progress.freq 1% 1%
session.upload_progress.min_freq 1 1
session.upload_progress.name PHP_SESSION_UPLOAD_PROGRESS PHP_SESSION_UPLOAD_PROGRESS
session.upload_progress.prefix upload_progress_ upload_progress_
session.use_cookies 1 1
session.use_only_cookies 1 1
session.use_strict_mode 0 0
session.use_trans_sid 0 0

Thanks!

Newbie

Posts

Joined
Sun Aug 07, 2022 2:24 pm

Post by Retaliate3476 » Thu Aug 11, 2022 7:41 am

Updated the first post with

PHP Version 7.4.8

Newbie

Posts

Joined
Sun Aug 07, 2022 2:24 pm

Post by by mona » Thu Aug 11, 2022 7:54 am

your htaccess is wrong

first you set the rewrite engine to on (not twice)
then set the rewrite base
then you do the rewrites

your cookie settings are also wrong, no secure, samesite, http only set at all.
why is your session cookie called __test?

you are not retaining your session this way i.e. not your language, currency or cart contents.

ps. you cannot comment blocks of lines by putting them between # characters in htaccess, that has to be done line by line.

DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.


https://www.youtube.com/watch?v=zXIxDoCRc84


User avatar
Expert Member

Posts

Joined
Mon Jun 10, 2019 9:31 am

Post by Retaliate3476 » Thu Aug 11, 2022 8:40 am

by mona wrote:
Thu Aug 11, 2022 7:54 am
your htaccess is wrong

first you set the rewrite engine to on (not twice)
then set the rewrite base
then you do the rewrites

your cookie settings are also wrong, no secure, samesite, http only set at all.
why is your session cookie called __test?

you are not retaining your session this way i.e. not your language, currency or cart contents.

ps. you cannot comment blocks of lines by putting them between # characters in htaccess, that has to be done line by line.
Hi Mona!

Can you please expand on this with what I can do to resolve?

"your cookie settings are also wrong, no secure, samesite, http only set at all."

Also, I have no idea why my session Cookie is called __test.. Where would I change that?

Thanks!!!!



######################################################################

Updated my htaccess file as per your comments :


# 1.To use URL Alias you need to be running apache with mod_rewrite enabled.

# 2. In your opencart directory rename htaccess.txt to .htaccess.

# For any support issues please visit: http://www.opencart.com

Options +FollowSymlinks

# Prevent Directory listing
Options -Indexes

# Prevent Direct Access to files
<FilesMatch "(?i)((\.tpl|\.twig|\.ini|\.log|(?<!robots)\.txt))">
Require all denied
## For apache 2.2 and older, replace "Require all denied" with these two lines :
# Order deny,allow
# Deny from all
</FilesMatch>

# SEO URL Settings
RewriteEngine On
# If your opencart installation does not run on the main web folder make sure you folder it does run in ie. / becomes /shop/

RewriteBase /htdocs/
RewriteRule ^sitemap.xml$ index.php?route=extension/feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=extension/feed/google_base [L]
RewriteRule ^system/storage/(.*) index.php?route=error/not_found [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

### Additional Settings that may need to be enabled for some servers
### Uncomment the commands by removing the # sign in front of it.
### If you get an "Internal Server Error 500" after enabling any of the following settings, restore the # as this means your host doesn't allow that.

# 1. If your cart only allows you to add one item at a time, it is possible register_globals is on. This may work to disable it:
php_flag register_globals off

# 2. If your cart has magic quotes enabled, This may work to disable it:
# php_flag magic_quotes_gpc Off

# 3. Set max upload file size. Most hosts will limit this and not allow it to be overridden but you can try
# php_value upload_max_filesize 999M

# 4. set max post size. uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields
# php_value post_max_size 999M

# 5. set max time script can take. uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields
# php_value max_execution_time 200

# 6. set max time for input to be recieved. Uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields
# php_value max_input_time 200

# 7. disable open_basedir limitations
php_admin_value open_basedir none

Newbie

Posts

Joined
Sun Aug 07, 2022 2:24 pm

Post by IP_CAM » Thu Aug 11, 2022 4:51 pm

I already told you, to get rid of this ???
RewriteBase /htdocs/

and leave it like this:
RewriteBase /

My Github OC Site: https://github.com/IP-CAM
5'200 + FREE OC Extensions, on the World's largest private Github OC Repository Archive Site.


User avatar
Legendary Member

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland

Post by ADD Creative » Thu Aug 11, 2022 5:58 pm

Retaliate3476 wrote:
Thu Aug 11, 2022 7:34 am
session.cookie_lifetime 86400
Change session.cookie_lifetime to 0. It's probably this bug. https://github.com/opencart/opencart/issues/8141

www.add-creative.co.uk


Expert Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by by mona » Thu Aug 11, 2022 7:56 pm

Best way to resolve : start again

1) Suggest you simply reinstate the default htaccess first.
this is one example of how to use https :-
https://isenselabs.com/posts/opencart-pages-https

The best people to ask about the best way to set the server to rewrite for https would be the people who provide you with your server.
You can search the forum, it has been asked and answered in every which way possible on various set ups.

2) where and why are you setting a "_test" cookie with an id value and an expiration of approx 1 year?
COOKIE.png

COOKIE.png (24.9 KiB) Viewed 937 times

3) the name of the session cookie which contains the session id is set in the config files under system, that is normally OCSESSID.
As stated above - the lifetime and domain and path are read from the php.ini file. lifetime should be set to zero there .
You are actually trying to set that cookie as you can see in the attached image but it does not get set and thus you lose the session.
This is probably because you set the expiration wrong, it should read "Session" and it reds "0".

Seach in the forum for the proper way to set cookies for secure, samesite, http only etc.
FYI use google to search - not the forum search

DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.


https://www.youtube.com/watch?v=zXIxDoCRc84


User avatar
Expert Member

Posts

Joined
Mon Jun 10, 2019 9:31 am

Post by Retaliate3476 » Sun Aug 14, 2022 1:16 pm

by mona wrote:
Thu Aug 11, 2022 7:56 pm
Best way to resolve : start again

1) Suggest you simply reinstate the default htaccess first.
this is one example of how to use https :-
https://isenselabs.com/posts/opencart-pages-https

The best people to ask about the best way to set the server to rewrite for https would be the people who provide you with your server.
You can search the forum, it has been asked and answered in every which way possible on various set ups.

2) where and why are you setting a "_test" cookie with an id value and an expiration of approx 1 year?
COOKIE.png

3) the name of the session cookie which contains the session id is set in the config files under system, that is normally OCSESSID.
As stated above - the lifetime and domain and path are read from the php.ini file. lifetime should be set to zero there .
You are actually trying to set that cookie as you can see in the attached image but it does not get set and thus you lose the session.
This is probably because you set the expiration wrong, it should read "Session" and it reds "0".

Seach in the forum for the proper way to set cookies for secure, samesite, http only etc.
FYI use google to search - not the forum search
Thanks Mona,

Got a support ticket open with the Hosting Provider re this issue.

Cheers,

Newbie

Posts

Joined
Sun Aug 07, 2022 2:24 pm
Who is online

Users browsing this forum: georgefeichter and 48 guests