Store Temporary Variables Using PHP?

Jason Axelrod

Okay, on my website, I have a lot of embedded pages for Twitch. Below all the embeds, I also have an authorization flow so that people can log into Twitch and click a follow button.

Normally, the flow would start at: mydomain.com/channel/name, and at the end of the flow, they would be returned to mydomain.com/auth. Originally, I had it so that the start URL would be stored in browser session storage using javascript; and then when they reach the final auth endpoint, I would use the javascript and pull the session storage and relocate them back to the original URL.

This has been working great... however, one of the features I have on my website is the ability to use custom canonical urls to proxy to their channel on my website. So someone could use theirdomain.com to proxy to mydomain.com/channel/them.

This created an issue with the session storage since session storage follows cross-domain restrictions. They would start at theirdomain.com and end at mydomain.com/auth. Since the domains don't match, I can't access the session storage to forward them back to the original URL.

I am using PHP, so I'm wondering what would be the best way to get around this. I figure instead of storing the start URL in session storage, I can save it using AJAX to temporary storage using PHP, linked to their IP addresses. However, I don't know how to do this.

Does PHP have some sort of temporary storage system with definable TTL? That also works across multiple domains? (it would be the same server)

DorianFM

If the request is proxied to the same application then the session is accessible, it's just the session identifier (which is stored in a cookie, hence the cross domain issue) which is causing the problem.

What you can do is pass the session identifier from one domain over the transition to the other domain, as part of a get request, so when you do the leap from theirdomain.comto example.com do it with a link formatted as http://example.com/blah/?session_id=[session_id_from cookie] (ideally using https).

Then on on example.com grab the session_id and use that to set the session_id in the cookie for that domain, and it will load the session from the source domain.

This can be used for session hijacking, but so can having your session_id in a cookie, so it's generally OK to do, though using https endpoints will improve security.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Store temporary variables c# winform

From Dev

Using PHP SESSION Variables to store MySQL query results

From Dev

Test condition without using temporary variables

From Dev

Test condition without using temporary variables

From Dev

Java optimization: declaring class variables VS using temporary variables

From Java

Why does PHP store uploaded files in a temporary location and what is the benefit?

From Dev

Upload file with PHP using a random temporary filename

From Dev

Where to store temporary files using a windows forms application

From Dev

Store original temporary uploaded image (to be deleted once filtered) using AWS

From Dev

How to write inside a dictionary entry in NSUserDefaults without using temporary variables?

From Dev

Comparing the output of 2 commands using test without temporary variables

From Dev

I am using Jquery to load dynamic php data into my file but cannot store the data into Javascript variables

From Dev

simple ruby calculator webpage, how to store temporary variables and process them on the same page with submit

From Dev

simple ruby calculator webpage, how to store temporary variables and process them on the same page with submit

From Dev

PHP calculation using variables

From Dev

Using PHP Variables in MySQL

From Dev

Using variables with PHP session

From Dev

Using session variables in php

From Dev

PHP Arithmetic using variables

From Dev

How to store variables in PHP for use in different scripts?

From Dev

Store PHP/SQL foreach form items in variables

From Dev

Store PHP/SQL foreach form items in variables

From Dev

Store PHP variables in an array, until the loop ends

From Dev

Read and store variables from JSON data in PHP

From Dev

temporary variables in a python expression

From Dev

SQL: Creating temporary variables

From Dev

Temporary variables in C

From Dev

Where to store globally accessible variables using Dancer

From Dev

Store data and global variables using the Application object

Related Related

  1. 1

    Store temporary variables c# winform

  2. 2

    Using PHP SESSION Variables to store MySQL query results

  3. 3

    Test condition without using temporary variables

  4. 4

    Test condition without using temporary variables

  5. 5

    Java optimization: declaring class variables VS using temporary variables

  6. 6

    Why does PHP store uploaded files in a temporary location and what is the benefit?

  7. 7

    Upload file with PHP using a random temporary filename

  8. 8

    Where to store temporary files using a windows forms application

  9. 9

    Store original temporary uploaded image (to be deleted once filtered) using AWS

  10. 10

    How to write inside a dictionary entry in NSUserDefaults without using temporary variables?

  11. 11

    Comparing the output of 2 commands using test without temporary variables

  12. 12

    I am using Jquery to load dynamic php data into my file but cannot store the data into Javascript variables

  13. 13

    simple ruby calculator webpage, how to store temporary variables and process them on the same page with submit

  14. 14

    simple ruby calculator webpage, how to store temporary variables and process them on the same page with submit

  15. 15

    PHP calculation using variables

  16. 16

    Using PHP Variables in MySQL

  17. 17

    Using variables with PHP session

  18. 18

    Using session variables in php

  19. 19

    PHP Arithmetic using variables

  20. 20

    How to store variables in PHP for use in different scripts?

  21. 21

    Store PHP/SQL foreach form items in variables

  22. 22

    Store PHP/SQL foreach form items in variables

  23. 23

    Store PHP variables in an array, until the loop ends

  24. 24

    Read and store variables from JSON data in PHP

  25. 25

    temporary variables in a python expression

  26. 26

    SQL: Creating temporary variables

  27. 27

    Temporary variables in C

  28. 28

    Where to store globally accessible variables using Dancer

  29. 29

    Store data and global variables using the Application object

HotTag

Archive