I have my php
files on a server
where i can access them using ajax
from my mobile app
.
I used Code-Igniter
from my mobile i sent first request in which it authenticates
a user and save all sessions
but when i sent next request
in which authentication
is required in that it gets nothing i think session
destroyed. So how i can handle this in CodeIgniter
previously i used custom style simple php
and it worked fine.
Asked
Active
Viewed 497 times
0

Blu
- 4,036
- 6
- 38
- 65
2 Answers
0
Try add this in .htaccess in your CI folder equal folder with CI index.php
Header add Access-Control-Allow-Origin "*"
Header add Access-Control-Allow-Headers "origin, x-requested-with, content-type"
Header add Access-Control-Allow-Methods "PUT, GET, POST, DELETE, OPTIONS"

user3349436
- 151
- 5
-
I used these in config/config.php `header('Access-Control-Allow-Origin: *'); header('Access-Control-Allow-Methods: GET, POST');` and my requests are reach properly – Blu Aug 29 '14 at 08:31
-
When i added those lines that you mentioned in answer it give me this error in console `Cross-Origin Request Blocked` – Blu Aug 29 '14 at 09:59
-
i don't have file at that position so i just make new and add above lines in that – Blu Aug 29 '14 at 10:27
-
do u place the mean .htaccess file in the same directory of CI index.php file? – user3349436 Aug 29 '14 at 10:30
-
yes in folder where index.php. But i have problem with saving seesion. Not accessing php files bcz i can access those files by adding this `header('Access-Control-Allow-Origin: *'); header('Access-Control-Allow-Methods: GET, POST');` in php file so it can accessable from different domains – Blu Aug 29 '14 at 10:34
-
Yups that way work properly too because I use it before create .htaccess file. I don't know whats wrong eith this problem but it run in my server. – user3349436 Aug 29 '14 at 10:37
-
hmm but I send first request with email it process and validate user and set them into session. But when i send another request for getting some data from table it fails to authenticates (i think empty session it found) and return 'first sign in' that is display message on failed. – Blu Aug 29 '14 at 10:41
0
I think in your application server
side on every request
you session starts
.
So its batter that first time you capture the SESSION Token
and when you make next request
that session token
pass along with other parameters
. All other session management
is the responsibility of servers.
Detail Source Below