Session destroyed after redirect in codeigniter 3
the issue i am facing is when i redirect to some page my session got destroyed. i am facing this issue in live server only and working flawlessly in localhost. this issue was not there few months ago on different hosting company
here is my session configuration
$config['sess_driver'] = 'files';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = NULL;
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;
$config['cookie_prefix'] = '';
$config['cookie_domain'] = '';
$config['cookie_path'] = '/';
$config['cookie_secure'] = FALSE;
$config['cookie_httponly'] = FALSE;
php codeigniter
add a comment |
the issue i am facing is when i redirect to some page my session got destroyed. i am facing this issue in live server only and working flawlessly in localhost. this issue was not there few months ago on different hosting company
here is my session configuration
$config['sess_driver'] = 'files';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = NULL;
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;
$config['cookie_prefix'] = '';
$config['cookie_domain'] = '';
$config['cookie_path'] = '/';
$config['cookie_secure'] = FALSE;
$config['cookie_httponly'] = FALSE;
php codeigniter
please compare and add CI and php version of localhost and production to the question
– Vickel
Nov 14 '18 at 19:21
It's a good idea to hard-code thesess_save_path
path. Also make sure to chmod 700 for the directory, see under 'Files driver' at codeigniter.com/user_guide/libraries/sessions.html
– jtheman
Nov 14 '18 at 19:34
can you tell me what to hardcode?
– Umer iqbal
Nov 14 '18 at 19:39
Have you read the link? You should add an absolute path to the sessions directory you want, and it should be a non public directory. The suggestion is/application/sessions
or equal depending on your environment. Then chmod it. Most probably the reason your sessions dont get stored on your new server is that CI can't save/read the session files. Another suggestion is using a database or memcached if you have, i'ts faster.
– jtheman
Nov 14 '18 at 19:51
some OS works fine with $config['sess_save_path'] = NULL like centOS while other server need path to store session. provide session path then check
– prasanna puttaswamy
Nov 15 '18 at 6:24
add a comment |
the issue i am facing is when i redirect to some page my session got destroyed. i am facing this issue in live server only and working flawlessly in localhost. this issue was not there few months ago on different hosting company
here is my session configuration
$config['sess_driver'] = 'files';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = NULL;
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;
$config['cookie_prefix'] = '';
$config['cookie_domain'] = '';
$config['cookie_path'] = '/';
$config['cookie_secure'] = FALSE;
$config['cookie_httponly'] = FALSE;
php codeigniter
the issue i am facing is when i redirect to some page my session got destroyed. i am facing this issue in live server only and working flawlessly in localhost. this issue was not there few months ago on different hosting company
here is my session configuration
$config['sess_driver'] = 'files';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = NULL;
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;
$config['cookie_prefix'] = '';
$config['cookie_domain'] = '';
$config['cookie_path'] = '/';
$config['cookie_secure'] = FALSE;
$config['cookie_httponly'] = FALSE;
php codeigniter
php codeigniter
asked Nov 14 '18 at 19:08
Umer iqbalUmer iqbal
9410
9410
please compare and add CI and php version of localhost and production to the question
– Vickel
Nov 14 '18 at 19:21
It's a good idea to hard-code thesess_save_path
path. Also make sure to chmod 700 for the directory, see under 'Files driver' at codeigniter.com/user_guide/libraries/sessions.html
– jtheman
Nov 14 '18 at 19:34
can you tell me what to hardcode?
– Umer iqbal
Nov 14 '18 at 19:39
Have you read the link? You should add an absolute path to the sessions directory you want, and it should be a non public directory. The suggestion is/application/sessions
or equal depending on your environment. Then chmod it. Most probably the reason your sessions dont get stored on your new server is that CI can't save/read the session files. Another suggestion is using a database or memcached if you have, i'ts faster.
– jtheman
Nov 14 '18 at 19:51
some OS works fine with $config['sess_save_path'] = NULL like centOS while other server need path to store session. provide session path then check
– prasanna puttaswamy
Nov 15 '18 at 6:24
add a comment |
please compare and add CI and php version of localhost and production to the question
– Vickel
Nov 14 '18 at 19:21
It's a good idea to hard-code thesess_save_path
path. Also make sure to chmod 700 for the directory, see under 'Files driver' at codeigniter.com/user_guide/libraries/sessions.html
– jtheman
Nov 14 '18 at 19:34
can you tell me what to hardcode?
– Umer iqbal
Nov 14 '18 at 19:39
Have you read the link? You should add an absolute path to the sessions directory you want, and it should be a non public directory. The suggestion is/application/sessions
or equal depending on your environment. Then chmod it. Most probably the reason your sessions dont get stored on your new server is that CI can't save/read the session files. Another suggestion is using a database or memcached if you have, i'ts faster.
– jtheman
Nov 14 '18 at 19:51
some OS works fine with $config['sess_save_path'] = NULL like centOS while other server need path to store session. provide session path then check
– prasanna puttaswamy
Nov 15 '18 at 6:24
please compare and add CI and php version of localhost and production to the question
– Vickel
Nov 14 '18 at 19:21
please compare and add CI and php version of localhost and production to the question
– Vickel
Nov 14 '18 at 19:21
It's a good idea to hard-code the
sess_save_path
path. Also make sure to chmod 700 for the directory, see under 'Files driver' at codeigniter.com/user_guide/libraries/sessions.html– jtheman
Nov 14 '18 at 19:34
It's a good idea to hard-code the
sess_save_path
path. Also make sure to chmod 700 for the directory, see under 'Files driver' at codeigniter.com/user_guide/libraries/sessions.html– jtheman
Nov 14 '18 at 19:34
can you tell me what to hardcode?
– Umer iqbal
Nov 14 '18 at 19:39
can you tell me what to hardcode?
– Umer iqbal
Nov 14 '18 at 19:39
Have you read the link? You should add an absolute path to the sessions directory you want, and it should be a non public directory. The suggestion is
/application/sessions
or equal depending on your environment. Then chmod it. Most probably the reason your sessions dont get stored on your new server is that CI can't save/read the session files. Another suggestion is using a database or memcached if you have, i'ts faster.– jtheman
Nov 14 '18 at 19:51
Have you read the link? You should add an absolute path to the sessions directory you want, and it should be a non public directory. The suggestion is
/application/sessions
or equal depending on your environment. Then chmod it. Most probably the reason your sessions dont get stored on your new server is that CI can't save/read the session files. Another suggestion is using a database or memcached if you have, i'ts faster.– jtheman
Nov 14 '18 at 19:51
some OS works fine with $config['sess_save_path'] = NULL like centOS while other server need path to store session. provide session path then check
– prasanna puttaswamy
Nov 15 '18 at 6:24
some OS works fine with $config['sess_save_path'] = NULL like centOS while other server need path to store session. provide session path then check
– prasanna puttaswamy
Nov 15 '18 at 6:24
add a comment |
1 Answer
1
active
oldest
votes
You are using the "files" driver so you must supply a path to $config['sess_save_path']
. You set the value to NULL which will not work.
The value assigned to $config['sess_save_path']
must be a full, absolute, path and must have the appropriate owner and permission settings. Documentation on the files driver.
For reasons of security, many devs create a folder on the same level as the website public folder. If that folder is named "sessions" then you could set the config like this
$config['sess_save_path'] = dirname(FCPATH .'/sessions/');
The other thing to try is being explicit with the cookie_domain, ie.
$config['cookie_domain'] = '.yourdomain.tld';
Be sure to include the leading dot.
tried this but nothing happens after that i tried using database the entries are there but session is still getting destroyed
– Umer iqbal
Nov 15 '18 at 10:44
Added something else to try.
– DFriend
Nov 15 '18 at 13:44
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53307178%2fsession-destroyed-after-redirect-in-codeigniter-3%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You are using the "files" driver so you must supply a path to $config['sess_save_path']
. You set the value to NULL which will not work.
The value assigned to $config['sess_save_path']
must be a full, absolute, path and must have the appropriate owner and permission settings. Documentation on the files driver.
For reasons of security, many devs create a folder on the same level as the website public folder. If that folder is named "sessions" then you could set the config like this
$config['sess_save_path'] = dirname(FCPATH .'/sessions/');
The other thing to try is being explicit with the cookie_domain, ie.
$config['cookie_domain'] = '.yourdomain.tld';
Be sure to include the leading dot.
tried this but nothing happens after that i tried using database the entries are there but session is still getting destroyed
– Umer iqbal
Nov 15 '18 at 10:44
Added something else to try.
– DFriend
Nov 15 '18 at 13:44
add a comment |
You are using the "files" driver so you must supply a path to $config['sess_save_path']
. You set the value to NULL which will not work.
The value assigned to $config['sess_save_path']
must be a full, absolute, path and must have the appropriate owner and permission settings. Documentation on the files driver.
For reasons of security, many devs create a folder on the same level as the website public folder. If that folder is named "sessions" then you could set the config like this
$config['sess_save_path'] = dirname(FCPATH .'/sessions/');
The other thing to try is being explicit with the cookie_domain, ie.
$config['cookie_domain'] = '.yourdomain.tld';
Be sure to include the leading dot.
tried this but nothing happens after that i tried using database the entries are there but session is still getting destroyed
– Umer iqbal
Nov 15 '18 at 10:44
Added something else to try.
– DFriend
Nov 15 '18 at 13:44
add a comment |
You are using the "files" driver so you must supply a path to $config['sess_save_path']
. You set the value to NULL which will not work.
The value assigned to $config['sess_save_path']
must be a full, absolute, path and must have the appropriate owner and permission settings. Documentation on the files driver.
For reasons of security, many devs create a folder on the same level as the website public folder. If that folder is named "sessions" then you could set the config like this
$config['sess_save_path'] = dirname(FCPATH .'/sessions/');
The other thing to try is being explicit with the cookie_domain, ie.
$config['cookie_domain'] = '.yourdomain.tld';
Be sure to include the leading dot.
You are using the "files" driver so you must supply a path to $config['sess_save_path']
. You set the value to NULL which will not work.
The value assigned to $config['sess_save_path']
must be a full, absolute, path and must have the appropriate owner and permission settings. Documentation on the files driver.
For reasons of security, many devs create a folder on the same level as the website public folder. If that folder is named "sessions" then you could set the config like this
$config['sess_save_path'] = dirname(FCPATH .'/sessions/');
The other thing to try is being explicit with the cookie_domain, ie.
$config['cookie_domain'] = '.yourdomain.tld';
Be sure to include the leading dot.
edited Nov 15 '18 at 13:44
answered Nov 14 '18 at 20:20
DFriendDFriend
7,0171521
7,0171521
tried this but nothing happens after that i tried using database the entries are there but session is still getting destroyed
– Umer iqbal
Nov 15 '18 at 10:44
Added something else to try.
– DFriend
Nov 15 '18 at 13:44
add a comment |
tried this but nothing happens after that i tried using database the entries are there but session is still getting destroyed
– Umer iqbal
Nov 15 '18 at 10:44
Added something else to try.
– DFriend
Nov 15 '18 at 13:44
tried this but nothing happens after that i tried using database the entries are there but session is still getting destroyed
– Umer iqbal
Nov 15 '18 at 10:44
tried this but nothing happens after that i tried using database the entries are there but session is still getting destroyed
– Umer iqbal
Nov 15 '18 at 10:44
Added something else to try.
– DFriend
Nov 15 '18 at 13:44
Added something else to try.
– DFriend
Nov 15 '18 at 13:44
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53307178%2fsession-destroyed-after-redirect-in-codeigniter-3%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
please compare and add CI and php version of localhost and production to the question
– Vickel
Nov 14 '18 at 19:21
It's a good idea to hard-code the
sess_save_path
path. Also make sure to chmod 700 for the directory, see under 'Files driver' at codeigniter.com/user_guide/libraries/sessions.html– jtheman
Nov 14 '18 at 19:34
can you tell me what to hardcode?
– Umer iqbal
Nov 14 '18 at 19:39
Have you read the link? You should add an absolute path to the sessions directory you want, and it should be a non public directory. The suggestion is
/application/sessions
or equal depending on your environment. Then chmod it. Most probably the reason your sessions dont get stored on your new server is that CI can't save/read the session files. Another suggestion is using a database or memcached if you have, i'ts faster.– jtheman
Nov 14 '18 at 19:51
some OS works fine with $config['sess_save_path'] = NULL like centOS while other server need path to store session. provide session path then check
– prasanna puttaswamy
Nov 15 '18 at 6:24