Jump to content

Not too hot with JS .. cookie question


xcandiottix

Recommended Posts

Does anyone know of a simple script in which I can just record the current url into?

 

For example:

I vist www.site.com/videos.html

 

I receive a cookie that says:

http://www.site.com/videos.html

 

or even better, just:

videos.html

 

I'm needing to save the cookie via html so a php include will know what page the visitor is viewing.

 

Thanks!

Link to comment
https://forums.phpfreaks.com/topic/204800-not-too-hot-with-js-cookie-question/
Share on other sites

I'm needing to save the cookie via html so a php include will know what page the visitor is viewing.

 

Huh? You can determine that easier with PHP. Take a look at the variables accessible via the array $_SERVER in PHP. http://php.net/manual/en/reserved.variables.server.php

 

I think you would want to use $_SERVER['PHP_SELF'], $_SERVER['QUERY_STRING'] or $_SERVER['REQUEST_URI']

  • 2 weeks later...

I acutally accomplished it like so:

 

Page 1:

<html>

<!--#set var="Current" value="$SCRIPT_NAME"-->

<meta http-equiv="refresh" content="0;url=next page">

</html>

 

Page 2:

$currentuserpage = $_SERVER['Current'];

$RtrimmedCUP = rtrim($currentuserpage, ".html");

$CUP = ltrim($RtrimmedCUP, "/users/");

$_COOKIE['CurrentPage'] = $CUP

 

 

Page one had to remain an HTML page so that's why I needed a work around. SSI was the answer, not js .. then the php page (2) got the var from the server.

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.