Welcome Guest, Not a member yet? Register   Sign In
session not setting?
#1

[eluser]codex[/eluser]
Hi,

I have a custom upload controller. In this controller there are 2 functions:

1 that shows the upload form, 1 that does the uploading of the files.

The second function is being called by a javascript (jQuery) that does the uploading. For each file that is being uploaded I want to add it to a session for further processing, but the session is not being set.

I've done a test like so, but nothing is being set. Why is that? And is there a way around it?
Code:
function upload_files()
{    
$_SESSION['test'] = true;
// rest of the code here etc
}

EDIT: Never mind. I think I've figured it out.
#2

[eluser]Armchair Samurai[/eluser]
Did you use session_start() before calling upload_files()?
#3

[eluser]codex[/eluser]
[quote author="Armchair Samurai" date="1195118539"]Did you use session_start() before calling upload_files()?[/quote]

No. I thought CI didn't require setting session_start()? Is it required then?
#4

[eluser]Alex007[/eluser]
You are using the native PHP session when you use $_SESSION, so yes you have to session_start().

Why don't you use the CI sessions ?
Code:
$this->session->set_userdata('uploadedfile', 'whattodo');
#5

[eluser]codex[/eluser]
[quote author="Alex007" date="1195176607"]You are using the native PHP session when you use $_SESSION, so yes you have to session_start().

Why don't you use the CI sessions ?
Code:
$this->session->set_userdata('uploadedfile', 'whattodo');
[/quote]

I'm using the 'Native session' library which (if I understand correctly) supports $_SESSION.
#6

[eluser]Alex007[/eluser]
[quote author="codex" date="1195180714"]
I'm using the 'Native session' library which (if I understand correctly) supports $_SESSION.[/quote]

I'd still use $this->session->set_userdata() , otherwise you are using a library that will never have a chance to call session_start() on its own.

Or you could call session_start() yourself.

But you're mixing stuff you shouldn't really mix together, if you have a library that encapsulates native sessions, why not use that library 100% of the time and let it do it's job ?




Theme © iAndrew 2016 - Forum software by © MyBB