Welcome Guest, Not a member yet? Register   Sign In
still losing session userdata across a redirect
#7

(This post was last modified: 12-01-2017, 08:01 AM by Narf.)

(I've reformatted the quotes to use code tags, please use that in the future)

(12-01-2017, 06:19 AM)richb201 Wrote:
Code:
$config['sess_expiration'] = 7200;
$config['sess_expiration'] = 0;

Just FYI, the second line overwrites the first ... there's no point in having both of them.

(12-01-2017, 06:19 AM)richb201 Wrote:
Code:
$config['sess_save_path'] = 'c:\xampp\htdocs\sub_crud\system\libraries\session';

This looks like the path to the library itself. You're not supposed to use that.

---

Still, neither of these can cause the problem. It can work perfectly well with all the settings you've shown.

(12-01-2017, 07:32 AM)richb201 Wrote:
(12-01-2017, 06:27 AM)PaulD Wrote: So sessions are working but when you use a redirect your session is resetting? Is that correct? If you session is resetting then flash data would be lost too of course.

Exactly. I can set the session userdata fine. And I can see that it is being written to at least one session file. In a typical test, 3 session files are created. One includes my data

Code:
__ci_last_regenerate|i:1512137748;isUserLoggedIn|b:1;userId|s:1:"1";userid|s:24:"cmljaGIyMDFAZ21haWwuY29t";[/fon

another one is blank. And the third has just [code]__ci_last_regenerate|i:1512137807;

The problem is after a redirect the $_SESSION is not being repopulated. I tried stopping the code at the fread to see if it was being read properly, but the file locking causes a crash if I do that.

I see many people posting with the same problem. I do need to be able to tell is the user has already been authenticated and the email of the user.
[/code]


Well, you see many people posting with the same symptom, not necessarily the same problem.

There's 2 general causes for this symptom to appear:

1. Session files (or otherwise server-side records) can't be written. A LOT of people simply don't read the documentation and don't set (properly) sess_save_path. This isn't the case here, though you should change to a better location.
2. Mismatching cookie parameters - what should be the problem here.

A cookie with the 'secure' flag can't be sent over plain HTTP (must be HTTPS).
A cookie set for domain foo.bar won't be sent to foo.baz, naturally.
A cookie set for path /foo won't be sent to /bar, also naturally.

You should also check/show your cookie settings.

(12-01-2017, 07:35 AM)richb201 Wrote:
(12-01-2017, 06:59 AM)dave friend Wrote: Try a trailing '\' on session_save_path.

I tried that Dave but that breaks everything.  Is \'  a special escape character? It seems to be the read that is the issue, not the write. Is there anyway to save the two fields I need  in a browser cookie, and then send it back to the server?

\ is an escape character; you need to escape it ... with itself, so that it is recognized as a literal one: \\
But that won't help. The library will automatically append it when missing.[/code]
Reply


Messages In This Thread
RE: still losing session userdata across a redirect - by Narf - 12-01-2017, 08:00 AM



Theme © iAndrew 2016 - Forum software by © MyBB