Welcome Guest, Not a member yet? Register   Sign In
Prevent cookie deleted when browser close
#1

(This post was last modified: 01-12-2023, 02:23 AM by nicojmb.)

Hi,

I've a simple funcion to set a coookie to save GPDR status.

PHP Code:
set_cookie('myweb_gpdr''accepted'0); 

This work great but if a close browser and reopen, the cookie not exists.


Can you helpme?

version: 4.3
Reply
#2

You are telling the cookie function to expire after 0 seconds. (3th parameter)

See: https://codeigniter.com/user_guide/helpe...set_cookie
Reply
#3

(This post was last modified: 01-12-2023, 12:55 PM by nicojmb.)

(01-12-2023, 11:27 AM)superior Wrote: You are telling the cookie function to expire after 0 seconds. (3th parameter)

See: https://codeigniter.com/user_guide/helpe...set_cookie

You are right, I thought "0" was permanent.

Changed to YEAR constant and work as spected.

PHP Code:
set_cookie('myweb_gpdr''accepted'YEAR); 

Regards!
Reply
#4

(01-12-2023, 11:27 AM)superior Wrote: You are telling the cookie function to expire after 0 seconds. (3th parameter)

See: https://codeigniter.com/user_guide/helpe...set_cookie

No. If the cookie expires after 0 seconds, you cannot use the cookie data at all.
If set to 0, the cookie will only last as long as the browser is open.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB