MySQL Forums
Forum List  »  PHP

Re: Session Problems with php and jquery
Posted by: Peter Brawley
Date: October 13, 2014 01:50PM

> I can't cache the info to session...

HTML is stateless. Your form-processing PHP script is starting an anonymous session that ceases to exist the moment it's finished. Your html page needs to become a php page, which will be your html page with this prepended ...

<?php
$session_name = 'myscriptname' . time();
session_name( $session_name );
session_start();
?>

Pass that session name in the AJAX call to the PHP script that processes the form, eg as a $_GET param named 'sess', and start that script with ...

<?php
if( !isset( $_GET['sess'] )) exit( "Session configuration error." );
$session_name = $_GET['sess'];
session_name( $session_name );
session_start();
...

Now anything the form-processing script adds to $_SESSION[] will be visible to the calling page.



Edited 1 time(s). Last edit at 10/13/2014 04:04PM by Peter Brawley.

Options: ReplyQuote


Subject
Written By
Posted
Re: Session Problems with php and jquery
October 13, 2014 01:50PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.