Post by moco123 » Sun Oct 18, 2020 12:28 pm

Hello, everyone,

I try to set up httponly for cookies, no matter I set in php.ini or .htaccess file, it doesn't work.

My website: Opencart 3.0.3.2 + Journal 3 them.
Server info: Apache 2.4/ litespeed/php7.3

Litespeed said' In Header always edit Set-Cookie ^(.*)$ $1;HttpOnly;Secure, edit is not supported'

https://www.litespeedtech.com/support/w ... es_by_lsws

What shall I do?

Thanks in advance!
Last edited by moco123 on Tue Jan 12, 2021 10:11 am, edited 1 time in total.

New member

Posts

Joined
Sun Oct 18, 2020 12:03 pm

Post by ADD Creative » Sun Oct 18, 2020 9:17 pm

You will probably have to find setcookie in the PHP files and add the flags you need.

For example these two locations for a start.
https://github.com/opencart/opencart/bl ... k.php#L108
https://github.com/opencart/opencart/bl ... on.php#L25

www.add-creative.co.uk


Guru Member

Posts

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

Post by moco123 » Tue Oct 20, 2020 6:53 am

Dear @ADD Creative,

Thanks for your help.
I think your idea is right. My server said that‘By default LiteSpeed has the Set-Cookie with a secure flag when served over HTTPS. It looks like these settings are actually being overwritten by the OpenCart script’.

According to your suggestion, I add 'ini_get('session.cookie_httponly')' to the files you mentioned. and set 'session.cookie_httponly = On' in php.ini flie. But still can't get the desired result.

I don't know if my settings are correct, I hope to get your further guidance.

Thanks again!

New member

Posts

Joined
Sun Oct 18, 2020 12:03 pm

Post by ADD Creative » Tue Oct 20, 2020 7:01 pm

You can't use session.cookie_httponly as this only affects the session cookie that OpenCart 3 does not use. You have to actually change the code.

Code: Select all

setcookie($config->get('session_name'), $session->getId(), ini_get('session.cookie_lifetime'), ini_get('session.cookie_path'), ini_get('session.cookie_domain', true, true));

www.add-creative.co.uk


Guru Member

Posts

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

Post by moco123 » Wed Oct 21, 2020 12:23 pm

Dear @ADD Creative,

Thanks for your help.
This issue maybe related to Journal theme also. If need your further help, I will contact you.

Thanks again.

New member

Posts

Joined
Sun Oct 18, 2020 12:03 pm

Post by ADD Creative » Fri Oct 23, 2020 6:57 pm

This post may be helpful. viewtopic.php?f=202&t=219596#p796736

www.add-creative.co.uk


Guru Member

Posts

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

Post by moco123 » Sat Jan 09, 2021 11:16 am

Sorry for late reply. Thanks for your suggestion. I have modified this issue.

New member

Posts

Joined
Sun Oct 18, 2020 12:03 pm
Who is online

Users browsing this forum: No registered users and 7 guests