Other Programming Languages
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreOther Programming Languages

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!
  #1  
Old May 4th, 2006, 04:53 PM
donpearson's Avatar
donpearson donpearson is offline
(,,,)( '.' )(,,,)
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Location: Looking at my screen
Posts: 476 donpearson User rank is Corporal (100 - 500 Reputation Level)donpearson User rank is Corporal (100 - 500 Reputation Level)donpearson User rank is Corporal (100 - 500 Reputation Level)donpearson User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 3 Days 11 h 45 m 57 sec
Reputation Power: 9
Pass php sessions with ajax

Hi all,

Im 100% new to ajax i have it all working apart from one thing...

How the hell do i pass php sessions with ajax ?

Can some one please help me...

I have been at this all day but its killing me now!

it is what i need to send it to

PHP Code:
 session_start();
$code strtoupper($_SESSION['code']);
$securitycode strtoupper($_POST['securitycode']); 
session_destroy(); 

if ((
$code == $securitycode) && (strlen($code) > 4)) {
echo 
'code is good';



so the session is $_SESSION['code']

Thanks
__________________
Midnight Fun

Last edited by donpearson : May 4th, 2006 at 05:07 PM.

Reply With Quote
  #2  
Old May 10th, 2006, 01:14 PM
donpearson's Avatar
donpearson donpearson is offline
(,,,)( '.' )(,,,)
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Location: Looking at my screen
Posts: 476 donpearson User rank is Corporal (100 - 500 Reputation Level)donpearson User rank is Corporal (100 - 500 Reputation Level)donpearson User rank is Corporal (100 - 500 Reputation Level)donpearson User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 3 Days 11 h 45 m 57 sec
Reputation Power: 9
Well that's a (__!__) i thought i may get some one that knows about this

Well it now looks like i will have to pull it all out and forget about it

Reply With Quote
  #3  
Old October 9th, 2007, 02:42 PM
Nukn Futz Nukn Futz is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2005
Location: Philly, Pa
Posts: 8 Nukn Futz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 43 m 18 sec
Reputation Power: 0
Quote:
Originally Posted by donpearson
Well that's a (__!__) i thought i may get some one that knows about this

Well it now looks like i will have to pull it all out and forget about it

I just got it working ... now my framework might be different then yours but as long as you have the $_SESSION['MyVar'] = 'something'; stored, you will just need to use the session_start() and then $something = $_SESSION['MyVar'] in your scripted called by AJAX.

I use AJAX in much the same way I use roll overs ... it's a small script included at the top of my page that just swaps the content of an ID w/ a PHP script results. I haven't gotten deep into the forms side of things which I feel is where AJAX really excels. In fact w/ all the issues I'm seeing w/ PHP and AJAX I'm not really sure I want to change my whole architecture. AJAX doesn't play well w/ PHP OO, in my opinion. i personally like to write all my own code so using plug ins like XOAD are cool but not my style. I'm looking into XOAD now to see if it is something I really want to get into, but like I said it's a major change from a pure PHP site. My biggest Issue is how calling PHP scripts in AJAX works ... I store commonly used site configuration info in a single array, connection to DBs have to happen on each script call, that requires passing of connection info, decentralizing my connection scripts to each php script that talks to the DB, and if you have more then one DB you're talking to it becomes a nightmare. I have ZENDCORE running on an IBM system i and connect to DB2 and MySQL. I'm in the process of looking how to integrate AJAX into that mix.

I've been thinking lately of proposing the Question to other programmers to see if they really think AJAX is worth the fight w/ PHP ... I'm just not sure.

Here is some code that may help .. "echo"'s are included for debuging.
This is loaded in a PHP function script included at the top of my main script.
Code:
<?php
	session_start();
		echo "Session ID = ".session_id()."<br />\n";
	$_SESSION['sql_host'] = $CFGVAR['sql_host'];
		echo "SQL Host = ".$_SESSION['sql_host']."<br />\n";
	$_SESSION['sql_user'] = $CFGVAR['sql_user'];
		echo "SQL User = ".$_SESSION['sql_user']."<br />\n";
	$_SESSION['sql_pass'] = $CFGVAR['sql_pass'];
		echo "SQL Password = ".$_SESSION['sql_pass']."<br />\n";
	$_SESSION['sql_database'] = $CFGVAR['sql_database'];
		echo "SQL Database = ".$_SESSION['sql_database']."<br />\n";
?> 

this a code snip it in the script called by AJAX
Code:
session_start();
	$sql_host = $_SESSION['sql_host'];
	$sql_user = $_SESSION['sql_user'];
	$sql_pass = $_SESSION['sql_pass'];
	$sql_database = $_SESSION['sql_database'];
	echo "SQL host = ".$sql_host."<BR />\n";
	echo "SQL user = ".$sql_user."<BR />\n";
	$userGroup = new select_UserGroup();
	$userGroup->dbOpen_MySQL($sql_host, $sql_user, $sql_pass, $sql_database);
	$userGroup->make_select_group();
	$userGroup->dbClose_MySQL($userGroup->db_con);


Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreOther Programming Languages > Pass php sessions with ajax


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway