How do I get PHP Sessions to work with construct 2

Get help using Construct 2

Post » Fri Apr 10, 2015 2:28 am

Im currently using AJAX plugin to post to a server and then i start a session like this

<?php
session_start();

$_SESSION['user'] = 'cat';

?>

Then i go to a different layout in construct 2 and i post to a different php script on the same server like this

<?php
session_start();

echo $_SESSION['user'];

?>

I get nothing back. The session variable is empty . The variables are not saving from one script to another.

Is this not going to work?

Ive been toying with this for days
B
3
Posts: 9
Reputation: 195

Post » Thu Apr 16, 2015 6:38 pm

It should work, to PHP its all the same session.

things to keep in mind:


-Origin access, add: header('Access-Control-Allow-Origin: *'); to the top of your PHP file.

-Ajax.LastData should have the result of your PHP Ajax request

-Check developer console during preview: hit CTRL SHIFT J in Chrome, and check the network tab, it should show the direct results of your request.
Who dares wins
B
57
S
17
G
21
Posts: 1,878
Reputation: 19,567

Post » Wed Jun 24, 2015 12:14 pm

hi,
i have the same problem
i have the header('Access-Control-Allow-Origin: *');
but problem still there..
if i open that php files with browser then work fine but if i use ajax in c2 The session variable is empty
@pugbreeder did you solve it ?
B
16
S
6
Posts: 243
Reputation: 1,755

Post » Wed Jun 24, 2015 12:33 pm

i export my project and it work fine !
so the problem is with the preview but i dont know what is the problem !
B
16
S
6
Posts: 243
Reputation: 1,755

Post » Sun Mar 26, 2017 5:16 pm

I need help for this to
B
10
S
4
G
1
Posts: 11
Reputation: 1,360


Return to How do I....?

Who is online

Users browsing this forum: unicornspitfire and 46 guests