/    Sign up×
Community /Pin to ProfileBookmark

transferring sessions

i have a page that requires a valid session to view it. the page has a link that pops up a small window. this small window requires a similar session to view it too. how could i pass the session from the parent window to this small window?
i did not have any session id from start. all i have is a session_start() and then i continue to store the info into the session variables.
thanks

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@zachzachJan 01.2005 — when you open the new window, make it like:

yourpage.whatever?s=<?PHP echo session_id(); ?>

on your new page:

<?PHP

session_id($_GET['s']);

session_start();

?>

There you go. Hope that helps.
Copy linkTweet thisAlerts:
@nairpraveenpJan 02.2005 — [i]Originally posted by zachzach [/i]

[B]when you open the new window, make it like:

yourpage.whatever?s=<?PHP echo session_id(); ?>



on your new page:

<?PHP

session_id($_GET['s']);

session_start();

?>



There you go. Hope that helps. [/B]
[/QUOTE]



hi zachzach,

just wondering, is this required? simple session_start() would have done that? ofcourse the above code is a possible solution if it 's not working. In my case , session_start() itself keeping the session for popups also. but when I tried to load a page with a different domain(since I'm using a shared certificate for secure transactions) the above code also dint work , it gave me an error saying read /write permission denied for the session flat file. what I understand is that since the secure url I'm using is of a different domain, eventhough though the file is in the same server.

for example from http://mydomain.com/cart.php , pop up loads https://some.securedomain.com/pay.php .


any suggestions please?
Copy linkTweet thisAlerts:
@phpnoviceJan 02.2005 — You cannot transfer a standard PHP session between domains.
Copy linkTweet thisAlerts:
@phpnoviceJan 02.2005 — [i]Originally posted by v[E]r5e [/i]

[B]i have a page that requires a valid session to view it. the page has a link that pops up a small window. this small window requires a similar session to view it too. how could i pass the session from the parent window to this small window?[/B][/QUOTE]

If the small window is in the same domain as the main window, then no special handling should be required. Both the main window and the small window should just use the following code as the first line in their respective pages:
[code=php]<?php
session_start();
?>[/code]

This function automatically determines whether a new session must be created or their is an existing session that must be recovered (reinstantiated). As mentioned, however, session recovery will only work within a single domain.
×

Success!

Help @v_E_r5e spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.5,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...